Answered by
5 years ago Edited 5 years ago
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:
1 | local teamChangerRemoteEvent = game.ReplicatedStorage.teamChangingEvent |
3 | script.Parent.MouseButton 1 Down:Connect( function () |
4 | local team = Brickcolor.new( "Really red" ) |
5 | teamChangeRemoveEvent:FireServer(team) |
**
in server script**
1 | local teamChangerRemoteEvent = game.ReplicatedStorage.teamChangingEvent |
3 | teamChangerRemoteEvent.OnServerEvent:Connect( function (player,team) |
4 | player.TeamColor = team |
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