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)

2 comments

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.

0

if newPlayer.Name ~= "Quibblish" then --[[code to play sound]] else --[[code to change team]] end