Help with teams

When I try to use my team changer then reset (to verify that it worked) I respawn at the same pad. I tested to see if it was just broken because of the scripted when I changed the team using a admin scripted and reset it respawned me at the right spawn point. I have no idea what the problem is.

local player = game.Players.LocalPlayer
local playername = player.Name

script.Parent.Activated:Connect(function()
	script.Parent.Parent.Visible = false	
	script.Parent.Parent.Parent.Parent.ChangeTeam.Enabled = true
end)

And it does change the player to the new team in the playerlist.

1 Like

That’s a local script, team change must be done via a serverscript

1 Like

Adding to what @jrdonat said, LocalPlayer cannot be accessed through a ServerScript as it will return as Nil.

Alternatives to finding the LocalPlayer can be found here:
https://devforum.roblox.com/t/replace-localplayer-in-a-server-script/529031