Script idea if player is on team then change brickcolor and material
Everything works but it always turns White even if I am on the Dark team. Any fixes?
local white = ("Institutional white") local black = ("Really black") local teams = game.Teams:GetTeams() script.Parent.Touched:connect(function(hit) player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then hey = player.TeamColor for idx = 1, #teams do local team = teams[idx] if team.Name == "Light" then script.Parent.BrickColor = BrickColor.new(white) script.Parent.Material = "Neon" break end if team.Name == "Dark" then script.Parent.BrickColor = BrickColor.new(black) script.Parent.Material = "Neon" break end end end end)
You never actually check to see what team the player is on. Rather, you just iterate the table, and every time the if statement is run, you break the function. Instead, you need to check the player's team color.
teams = game:GetService("Teams"):GetTeams() script.Parent.Touched:connect(function(hit) player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then for i = 1, #teams do team = teams[i] if team.TeamColor = player.TeamColor then script.Parent.BrickColor = BrickColor.new(team.TeamColor) script.Parent.Material = "Neon" end end end end end)