Teleport Button problem

Hi guys! I have a problem. I made three teams, and added colors to it, and made for every team a spawn, with the same color, which I gave to the teams. And I made a team changer gui too. And everything works fine, because when the player joins to the game, they automatically joins to the “Menu” team. The game waits for the players action. After the player selected the team, the spawn is brokes for the selected team. How can I fix this?

So there’s my teams:

And there’s my GUI:

Here’s the code from the TeamGui → Background → PlayAsARed → PlayButtonScript:

local p = script.Parent.Parent.Parent.Parent.Parent.Name

	game.Players[p].TeamColor ="Really red")
	script.Parent.Parent.Parent.Enabled = false
	game.Workspace[p].Humanoid.Health = 0

If anyone can help, to make this teleporting possible through this code, please write down to the comments your solutions! Thanks for everyvone! Have a nice day! :slight_smile:

1 Like

Never put server scripts in a Gui. Use a local script to fire a remote event to the server

1 Like

use LoadCharacter instead of changing the health to 0

local p = script.Parent.Parent.Parent.Parent.Parent

	script.Parent.Parent.Parent.Enabled = false
	p.Team = game:GetService("Teams").Red


Error against :confused:

change the LocalScript to a Script

1 Like

Thanks for your answer! Mr. Ping :smiley: