Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't this script change my team when I set my own teamcolor to that of a corresponding team?

Asked by 4 years ago

This script is supposed to play a sound when someone who isn't me enters the game and change my team when I join the game. The sound playing works, but the team changing doesn't. Can you help me figure this out?

function Enter(newPlayer)
wait()
if newPlayer.name ~= "Quibblish" then
newPlayer:WaitForChild("Backpack"):WaitForChild("Sound"):Play()
if newPlayer.name == "Quibblish" then
game.Players[newPlayer.Name].Neutral = false
game.Players[newPlayer.Name].TeamColor = game.Teams.Quibblish.TeamColor
end
end
end
game.Players.ChildAdded:connect(Enter)
0
Your if-statement is nested. Line 5 will never be true because line 3 isn't true and line 5 is nested inside line 3's scope. Use 'else' instead and forget about the condition. pidgey 548 — 4y
0
if newPlayer.Name ~= "Quibblish" then --[[code to play sound]] else --[[code to change team]] end pidgey 548 — 4y

Answer this question