I'm not going to guarantee this, but I think I spotted your issue.
4 | t.Handle.Transparency = 1 |
5 | v.Head.Face.Transparency = 1 |
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.
01 | if t:IsA 'Part' or t:IsA 'Hat' then |
07 | t.Handle.Transparency = 1 |
08 | v.Head.Face.Transparency = 1 |
The finalized (fixed) script:
001 | local player = game.Players.LocalPlayer |
002 | local char = player.Character |
005 | for _, v in pairs (game.Players:GetChildren()) do |
006 | if v.Name = = player.Name then |
008 | elseif v:IsA 'Player' then |
009 | for p, t in pairs (v.Character:GetChildren()) do |
010 | if t:IsA 'Part' or t:IsA 'Hat' then |
015 | t.Handle.Transparency = 1 |
016 | v.Head.Face.Transparency = 1 |
023 | game.Players.PlayerAdded:connect( function (newPlayer) |
024 | if player.PlayerService.PlayerTeam.Value = = BrickColor.new( "White" ) then |
025 | for _, v in pairs (game.Players:GetChildren()) do |
026 | if v.Name = = player.Name then |
028 | elseif v:IsA 'Player' then |
029 | for p, t in pairs (v.Character:GetChildren()) do |
030 | if t:IsA 'Part' or t:IsA 'Hat' then |
035 | t.Handle.Transparency = 1 |
036 | v.Head.Face.Transparency = 1 |
045 | player.PlayerService.PlayerTeam.changed:connect( function (val) |
047 | if val = = BrickColor.new( "White" ) then |
048 | for _, v in pairs (game.Players:GetChildren()) do |
049 | if v.Name = = player.Name then |
051 | elseif v:IsA 'Player' then |
052 | for p, t in pairs (v.Character:GetChildren()) do |
053 | if t:IsA 'Part' or t:IsA 'Hat' then |
058 | t.Handle.Transparency = 1 |
059 | v.Head.Face.Transparency = 1 |
068 | player.PlayerService.PlayerTeam.changed:connect( function (val) |
070 | if val = = BrickColor.new( "Bright red" ) then |
071 | for _, v in pairs (game.Players:GetChildren()) do |
072 | if v.Name = = player.Name then |
074 | elseif v:IsA 'Player' then |
075 | for p, t in pairs (v.Character:GetChildren()) do |
077 | t.Transparency = 0.75 |
078 | t.BrickColor = BrickColor.new( "Bright red" ) |
079 | elseif t:IsA 'Hat' then |
081 | v.Head.Face.Transparency = 0.75 |
089 | player.PlayerService.PlayerTeam.changed:connect( function (val) |
090 | if val = = BrickColor.new( "Medium stone grey" ) then |
091 | for _, v in pairs (game.Players:GetChildren()) do |
092 | if v.Name = = player.Name then |
094 | elseif v:IsA 'Player' then |
095 | for p, t in pairs (v.Character:GetChildren()) do |
096 | if t:IsA 'Part' or t:IsA 'Hat' then |
101 | t.Handle.Transparency = 1 |
102 | v.Head.Face.Transparency = 1 |
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:
01 | player.PlayerService.PlayerTeam.changed:connect( function (val) |
03 | if val = = BrickColor.new( "Bright red" ) then |
04 | for _, v in pairs (game.Players:GetChildren()) do |
05 | if v.Name = = player.Name then |
07 | elseif v:IsA 'Player' then |
08 | for p, t in pairs (v.Character:GetChildren()) do |
11 | t.BrickColor = BrickColor.new( "Bright red" ) |
12 | elseif t:IsA 'Hat' then |
14 | v.Head.Face.Transparency = 0.75 |
Modified:
01 | player.PlayerService.PlayerTeam.changed:connect( function (val) |
03 | if val = = BrickColor.new( "Bright red" ) then |
04 | for _, v in pairs (game.Players:GetChildren()) do |
05 | if v.Name = = player.Name then |
07 | elseif v:IsA 'Player' then |
08 | for p, t in pairs (v.Character:GetChildren()) do |
09 | if t:IsA 'Part' or t:IsA 'Hat' then |
12 | t.BrickColor = BrickColor.new( "Bright red" ) |
16 | v.Head.Face.Transparency = 0.75 |
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.