-
What do you want to achieve? A surfacegui text button in which the script inside it only runs if the player who clicked it has a certain team color.
-
What is the issue? Everytime I try to make the button’s script work by getting the players teamcolor value, it gives me the error “attempt to index nil with ‘TeamColor’”
-
What solutions have you tried so far? The 2nd script I showed all the way below.
script.Parent.MouseButton1Click:connect(function(GetCar)
Mod = game.ServerStorage.TestCar
clone = Mod:clone()
clone.Parent = workspace
clone:MakeJoints()
script.Parent.Parent.SpawnCar2.Visible = true
script.Parent:Destroy()
end)
This was my try at trying to achieve my goal (which inevitably gave me that “attempt to index nil with ‘TeamColor’” error. (Below)
script.Parent.MouseButton1Click:connect(function(player)
if player.TeamColor == "Bright blue" then
Mod = game.ServerStorage.TestCar
clone = Mod:clone()
clone.Parent = workspace
clone:MakeJoints()
end
end)