Team choose gui not changing teams

I have a team changer GUI that when I click to choose a team it won’t change me to that team but keeps me in neutral. I don’t know what is wrong with the code. Here is the code:

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

script.Parent.MouseButton1Click:Connect(function()

game.Players[p].TeamColor = BrickColor.new("Maroon")

game.Workspace[p].Humanoid.Health = 0

script.Parent.Parent.Parent.Enabled = false

end)

It won’t work. Here is a video:

This could be due to how you have your “Teams” set up, the SpawnLocation TeamColors should match up with what your Team Colors are I believe

i just got a spawn location and went to its properties and made the team color the same one for the raider teams

check if neutral property is ticked on the spawn, if it is untick it.

nope. the raider spawn is not ticked.

can you show me the properties of you raider spawn?

Ateam

The color of the spawn is normal white but the team color property is maroon? Is that a problem?

anything in the output? no the colour of the spawn is not the problem. check if your other spawns have neutral ticked.

I removed the unused spawns and only kept the raider and neutral spawn. It still doesn’t work

Parent.Name, remove name and try.

Players.ForgottenDogYT.PlayerGui.TeamGUI.Frame.RaiderButton.Script:4: invalid argument #2 (string expected, got Instance)

Error message

never mind add name back, my mistake.

1 Like

I added it back. No error but still doesn’t work

I am guessing this is a local script, right?

Its a normal script. Its not a local script

Pretty sure it has to be a local script

well. I changed it to a local script and it still wont change the teams

I think I know, give me a second please.

1 Like

So basically you cant change a player’s team from the client, you can only change it from the server.

so how can I do it for it to work?