Team does not switch when you press the button

Hey all, I need some help with this bug that is happening with my script. No error, just not swapping teams when the button is clicked. I am a starter scripter, so please forgive me for me being kinda bad at scripting lol.

Remote event code:

Local script code:

you might need to put a wait like task.wait(.2) before printing team

I’m not sure on why this isn’t working unless there is a naming issue or if the team doesn’t exist yet when the server side code runs. If you’re only relying on using print(player.Team) to check if the team was changed then you may need to add task.wait(1) before doing so as there is a delay between using :FireServer() and the remote event code running.

Otherwise have you tried doing

employeeEvent.OnServerEvent:Connect(function(plr)
    plr.Team = game.Teams.Employee
end)

instead of using :WaitForChild("Employee")
This is better practice as well if the team 100% exists.

Try setting the player’s teamColor to the teamColor of the team you want it to change to instead of the team itself.
Ex: plr.TeamColor = (team color of the team you want)

Where is the LocalScript located? It doesn’t work in Workspace and other places.

maybe try using “player” instead of “plr” im not sure if it will work but try it!

It’s placed inside the gui that the buttons are placed in.

Worked, i’m actually an idiot for not realizing that💀

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.