In this script there are 3 simple things that are suppose to happen. If your on :
player.PlayerService.PlayerTeam.Value = BrickColor.new"White"
then all other players are completely invisible.
If you are on:
player.PlayerService.PlayerTeam.Value = BrickColor.new"Medium stone grey"
then everyone is completely visible
If you are on:
player.PlayerService.PlayerTeam.Value = BrickColor.new"Bright red"
Then all other players are transparent and red
I have tested this script in studio with a server of 2 players, it worked in both cases. But when I asked my brother and sister to test it with me the transparency part didn't work, but when the game started one of them turned transparent red. My game is set up very specifically with lots of int values and string values for the players. If you have any questions on why something is the way it is, ill answer that question.
Here is the script:
local player = game.Players.LocalPlayer local char = player.Character wait() for _, v in pairs(game.Players:GetChildren()) do if v.Name == player.Name then wait() elseif v:IsA'Player' then for p, t in pairs (v.Character:GetChildren()) do if t:IsA'Part' then t.Transparency = 1 elseif t:IsA'Hat' then t.Handle.Transparency = 1 v.Head.Face.Transparency = 1 end end end end game.Players.PlayerAdded:connect(function (newPlayer) if player.PlayerService.PlayerTeam.Value == BrickColor.new("White") then for _, v in pairs(game.Players:GetChildren()) do if v.Name == player.Name then wait() elseif v:IsA'Player' then for p, t in pairs (v.Character:GetChildren()) do if t:IsA'Part' then t.Transparency = 1 elseif t:IsA'Hat' then t.Handle.Transparency = 1 v.Head.Face.Transparency = 1 end end end end end end) player.PlayerService.PlayerTeam.changed:connect(function(val) wait() if val == BrickColor.new("White") then for _, v in pairs(game.Players:GetChildren()) do if v.Name == player.Name then wait() elseif v:IsA'Player' then for p, t in pairs (v.Character:GetChildren()) do if t:IsA'Part' then t.Transparency = 1 elseif t:IsA'Hat' then t.Handle.Transparency = 1 v.Head.Face.Transparency = 1 end end end end end end) player.PlayerService.PlayerTeam.changed:connect(function(val) wait() if val == BrickColor.new("Bright red") then for _, v in pairs(game.Players:GetChildren()) do if v.Name == player.Name then wait() elseif v:IsA'Player' then for p, t in pairs (v.Character:GetChildren()) do if t:IsA'Part' then t.Transparency = 0.75 t.BrickColor = BrickColor.new("Bright red") elseif t:IsA'Hat' then t:Destroy() v.Head.Face.Transparency = 0.75 end end end end end end) player.PlayerService.PlayerTeam.changed:connect(function(val) if val == BrickColor.new("Medium stone grey") then for _, v in pairs(game.Players:GetChildren()) do if v.Name == player.Name then wait() elseif v:IsA'Player' then for p, t in pairs (v.Character:GetChildren()) do if t:IsA'Part' then t.Transparency = 0 elseif t:IsA'Hat' then t.Handle.Transparency = 0 v.Head.Face.Transparency = 1 end end end end end end)
I'm not going to guarantee this, but I think I spotted your issue.
if t:IsA'Part' then t.Transparency = 1 elseif t:IsA'Hat' then t.Handle.Transparency = 1 v.Head.Face.Transparency = 1 end
If I recall properly, I'm pretty sure that elseif will nullify if the first condition is correct, but don't quote me on this.
Basically, If the first "If" statement is viable, in this case, if t is a part, then it will run that and end the script, simple as that. However, if it isn't a part, then it will resort to the "elseif" statement, which is to see if t is a hat.
I'm pretty sure this is how if functions work, if I recall properly, but yet again, don't quote me on this.
Also, the correct format of those lines.
if t:IsA'Part' or t:IsA'Hat' then --this allows both to be checked at the same time if t:IsA'Part' then --if its a part then... (game will skip the function if not viable) t.Transparency = 1 end if t:IsA'Hat' then --if its a hat then... t.Handle.Transparency = 1 v.Head.Face.Transparency = 1 end end
The finalized (fixed) script:
local player = game.Players.LocalPlayer local char = player.Character wait() for _, v in pairs(game.Players:GetChildren()) do if v.Name == player.Name then wait() elseif v:IsA'Player' then for p, t in pairs (v.Character:GetChildren()) do if t:IsA'Part' or t:IsA'Hat' then if t:IsA'Part' then t.Transparency = 1 end if t:IsA'Hat' then t.Handle.Transparency = 1 v.Head.Face.Transparency = 1 end end end end end game.Players.PlayerAdded:connect(function (newPlayer) if player.PlayerService.PlayerTeam.Value == BrickColor.new("White") then for _, v in pairs(game.Players:GetChildren()) do if v.Name == player.Name then wait() elseif v:IsA'Player' then for p, t in pairs (v.Character:GetChildren()) do if t:IsA'Part' or t:IsA'Hat' then if t:IsA'Part' then t.Transparency = 1 end if t:IsA'Hat' then t.Handle.Transparency = 1 v.Head.Face.Transparency = 1 end end end end end end end) player.PlayerService.PlayerTeam.changed:connect(function(val) wait() if val == BrickColor.new("White") then for _, v in pairs(game.Players:GetChildren()) do if v.Name == player.Name then wait() elseif v:IsA'Player' then for p, t in pairs (v.Character:GetChildren()) do if t:IsA'Part' or t:IsA'Hat' then if t:IsA'Part' then t.Transparency = 1 end if t:IsA'Hat' then t.Handle.Transparency = 1 v.Head.Face.Transparency = 1 end end end end end end end) player.PlayerService.PlayerTeam.changed:connect(function(val) wait() if val == BrickColor.new("Bright red") then for _, v in pairs(game.Players:GetChildren()) do if v.Name == player.Name then wait() elseif v:IsA'Player' then for p, t in pairs (v.Character:GetChildren()) do if t:IsA'Part' then t.Transparency = 0.75 t.BrickColor = BrickColor.new("Bright red") elseif t:IsA'Hat' then t:Destroy() v.Head.Face.Transparency = 0.75 end end end end end end) player.PlayerService.PlayerTeam.changed:connect(function(val) if val == BrickColor.new("Medium stone grey") then for _, v in pairs(game.Players:GetChildren()) do if v.Name == player.Name then wait() elseif v:IsA'Player' then for p, t in pairs (v.Character:GetChildren()) do if t:IsA'Part' or t:IsA'Hat' then if t:IsA'Part' then t.Transparency = 1 end if t:IsA'Hat' then t.Handle.Transparency = 1 v.Head.Face.Transparency = 1 end end end end end end end)
ALSO, line 59 to 78 I might have spotted a similar error, so if it still doesn't work try replacing those lines with the following code:
Original:
player.PlayerService.PlayerTeam.changed:connect(function(val) wait() if val == BrickColor.new("Bright red") then for _, v in pairs(game.Players:GetChildren()) do if v.Name == player.Name then wait() elseif v:IsA'Player' then for p, t in pairs (v.Character:GetChildren()) do if t:IsA'Part' then t.Transparency = 0.75 t.BrickColor = BrickColor.new("Bright red") elseif t:IsA'Hat' then t:Destroy() v.Head.Face.Transparency = 0.75 end end end end end end)
Modified:
player.PlayerService.PlayerTeam.changed:connect(function(val) wait() if val == BrickColor.new("Bright red") then for _, v in pairs(game.Players:GetChildren()) do if v.Name == player.Name then wait() elseif v:IsA'Player' then for p, t in pairs (v.Character:GetChildren()) do if t:IsA'Part' or t:IsA'Hat' then if t:IsA'Part' then t.Transparency = 0.75 t.BrickColor = BrickColor.new("Bright red") end if t:IsA'Hat' then t:Destroy() v.Head.Face.Transparency = 0.75 end end end end end end end)
PS: If you want to get the finalized code without all the #'s if you CTRL+C & CTRL+V'd it, just look at the source by highlighting the code and then pressing the button that has the white page and the <> signs.