Team changing but does not say its changing

I am trying to make a script that changes a team when clicked a gui, but the problem is it doesnt say it is changing the team in chat and all the scripts for that team does not work because it thinks i am not in the team.

my local script:

local button = script.Parent

local button = script.Parent

local function onButtonActivated()
local player = game.Players.LocalPlayer
local teamName = “Traitor”
local buyer = script.Parent.Parent.Parent.Parent.Parent
cash = buyer.leaderstats[“Cash”]

if cash.Value < 500 then return end 

if cash.Value >= 500 then

	player.Team = game.Teams[teamName] 
	cash.Value = cash.Value - 500


end

end
button.Activated:Connect(onButtonActivated)

im new to this site i dont know how to put in the full script into the box

You’ll need to fire a remote to the server and have it change the team there, changing the team on the client does not replicate to the server.