Team change not working

I am trying to make a script where it will change the players team when they click a button if they are in a certain group as seen in my code below:

 script.Parent.MouseButton1Click:connect(function()
	if script.Parent.Parent.Parent.Parent:IsInGroup(11750790) then
		script.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Cocoa")
		script.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0
end

However, the script I created is not working. What did I do wrong and how do I fix it?
If it helps, this is my explorer tab:

GuiTeamChangeExplorer

Any help would be greatly appreciated!

groupId = 11750790

script.Parent.MouseButton1Click:Connect(function(Player)
    if Player:IsInGroup(groupId) then
        Player.TeamColor = BrickColor.new("Cocoa")
        Player.Character:LoadCharacter()
    end
end)

I tried this and it still doesn’t change the players team for some reason

Can you even change player teams locally?

I do not believe so.

R A N D O M T E X T

Oh I didn’t realize I was using a local script my bad. What should I use instead?

A regular script. If you wanted something to trigger the team change locally, like a TextButton or something of the sort, you’d need a RemoteEvent.