Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I want to make Teamchanger gui but script is wrong?

Asked by 5 years ago
plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function(click)

    plr.TeamColor = BrickColor.new("Really red")

end)
0
well if you change the team with a local script its not going to replicate to the server EnderPowerHD 98 — 5y
0
In this case, you need a remote event and a server script. namespace25 594 — 5y

2 answers

Log in to vote
0
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:

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

Ad
Log in to vote
-1
Answered by 5 years ago
Edited 5 years ago

plr = game.Players.LocalPlayer mouse = plr:GetMouse() mouse.Button1Down:Connect(function(click) plr.TeamColor = BrickColor.new("Really red") end)

Answer this question