daily pastebin goal
40%
SHARE
TWEET

Hide Fans

a guest Jan 11th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local PLAYERS = game:GetService("Players")
  2.  
  3. local characterConnections = {}
  4.  
  5. local function hide(obj)
  6.     if obj:IsA"BasePart" or obj:IsA"Decal" then
  7.         obj.Transparency = 1
  8.     elseif obj:IsA"ParticleEmitter" then
  9.         obj:Destroy()
  10.     end
  11. end
  12.  
  13.  
  14. local function makeInvisible(player)
  15.     local character = player.Character or player.CharacterAdded:Wait()
  16.    
  17.     for _, thing in next, character:GetDescendants() do
  18.         hide(thing)
  19.     end
  20.    
  21.     if characterConnections[player.UserId] then
  22.         characterConnections[player.UserId]:Disconnect();
  23.     end
  24.     characterConnections[player.UserId] = character.DescendantAdded:Connect(function(part)
  25.         hide(part)
  26.     end)
  27. end
  28.  
  29.  
  30. for _, player in next, PLAYERS:GetPlayers() do
  31.     if player.Character then
  32.         makeInvisible(player)
  33.     end
  34.    
  35.     characterConnections[player.UserId .. "_charadded"] = player.CharacterAdded:Connect(function()
  36.         makeInvisible(player)
  37.     end)
  38. end
  39.  
  40.  
  41.  
  42.  
  43. local teamConnections = {}
  44.  
  45. PLAYERS.PlayerAdded:Connect(function(player)
  46.     if player.Character and player.Team == game.Teams.Fans then
  47.         makeInvisible(player)
  48.     end
  49.    
  50.     characterConnections[player.UserId .. "_charadded"] = player.CharacterAdded:Connect(function()
  51.         if player.Team == game.Teams.Fans then
  52.             makeInvisible(player)
  53.         end
  54.     end)
  55.    
  56.     teamConnections[player.UserId] = player:GetPropertyChangedSignal"Team":Connect(function()
  57.         if player.Character and player.Team == game.Teams.Fans then
  58.             makeInvisible(player)
  59.         end
  60.     end)
  61. end)
  62.  
  63.  
  64. PLAYERS.PlayerRemoving:Connect(function(player)
  65.     if characterConnections[player.UserId .. "_charadded"] then
  66.         characterConnections[player.UserId .. "_charadded"]:Disconnect(); characterConnections[player.UserId .. "_charadded"] = nil
  67.     end
  68.     if characterConnections[player.UserId] then
  69.         characterConnections[player.UserId]:Disconnect(); characterConnections[player.UserId] = nil
  70.     end
  71.     if teamConnections[player.UserId] then
  72.         teamConnections[player.UserId]:Disconnect(); teamConnections[player.UserId] = nil
  73.     end
  74. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top