Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I want to make Teamchanger gui but script is wrong?

plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function(click)
	
	plr.TeamColor = BrickColor.new("Really red")
	
end)

2 comments

0

well if you change the team with a local script its not going to replicate to the server

0

In this case, you need a remote event and a server script.

2 answers

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.