plr = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function(click) plr.TeamColor = BrickColor.new("Really red") end)
you need remote event, Local script, and server script.
put the remote event in replicated storage, put the server script in server script service, and finally put the Local Script in the button that will be clicked to change teams,
in local script:
local teamChangerRemoteEvent = game.ReplicatedStorage.teamChangingEvent -- change to the directory of the remote event script.Parent.MouseButton1Down:Connect(function() local team =Brickcolor.new("Really red") -- change to the team that the player wil go to teamChangeRemoveEvent:FireServer(team) end)
** in server script**
local teamChangerRemoteEvent = game.ReplicatedStorage.teamChangingEvent -- change to the directory of the remote event teamChangerRemoteEvent.OnServerEvent:Connect(function(player,team) player.TeamColor = team end)
remember this:
when the server is called: the first argument that's passed to FireServer()
will be the second argument to the handler function that's connected to OnServerEvent
. The first argument to OnServerEvent
is the player that fired the server
plr = game.Players.LocalPlayer mouse = plr:GetMouse() mouse.Button1Down:Connect(function(click) plr.TeamColor = BrickColor.new("Really red") end)