function onTouched(part) local character = part.Parent local players = game:GetService("Players") local player = players:GetPlayerFromCharacter(part.Parent) local shirt = character:FindFirstChildOfClass("Shirt") local pants = character:FindFirstChildOfClass("Pants") if player then if not shirt then shirt = Instance.new("Shirt", character) end if not pants then pants = Instance.new("Pants", character) end if player.Team == "Red" then shirt.ShirtTemplate = "rbxassetid://136056214" pants.PantsTemplate = "rbxassetid://136056214" end if player.Team == "Blue" then shirt.ShirtTemplate = "rbxassetid://136056667" pants.PantsTemplate = "rbxassetid://136056667" end end end script.Parent.Touched:Connect(onTouched)
The Team
property returns an object value (the Team in game.Teams
). In lines 14-21 you should be doing:
if player.Team.Name == "Red" then shirt.ShirtTemplate = "rbxassetid://136056214" pants.PantsTemplate = "rbxassetid://136056214" end if player.Team.Name == "Blue" then shirt.ShirtTemplate = "rbxassetid://136056667" pants.PantsTemplate = "rbxassetid://136056667" end
Therefore, your script was passing the check on the player, but it wasn't passing either of these, as you were checking if an object value was equal to a string value.
Resources:
Accept and upvote if this helps!