No im not using a remote event
Here is the script responsible:
local Jobs = game.Teams:WaitForChild("any team")
local Player = game.Players.LocalPlayer
script.Parent.MouseButton1Down:Connect(function()
Player.Team = Jobs
end)
No im not using a remote event
Here is the script responsible:
local Jobs = game.Teams:WaitForChild("any team")
local Player = game.Players.LocalPlayer
script.Parent.MouseButton1Down:Connect(function()
Player.Team = Jobs
end)
If this is a server script, it wonât work because you can only get the LocalPlayer from a LocalScript. If this is a LocalScript, it will not change the team on the server. So something is wrong here.
Yes it is a local script. could the rate chnage in the localscript?
If itâs a LocalScript, that means you are not changing the playerâs team on the server. Which means, the server script wonât detect any team change (so the pay rate wonât change because it will look like you arenât changing teams). Fire a RemoteEvent from the LocalScript when the team changes and send the teamâs name as a data. Receive that data in a Server Script, and change the playerâs team on the server too.
Can you show a example of this please?
First, create a RemoteEvent in ReplicatedStorage (it doesnât have to be there to work but Roblox devs typically put it in there). Now name your RemoteEvent something like TeamChange or TeamChangeEvent. From your LocalScript, fire that RemoteEvent with the team in it as a data:
local Jobs = game.Teams:WaitForChild("any team")
script.Parent.MouseButton1Down:Connect(function()
game.ReplicatedStorage.TeamChangeEvent:FireServer(Jobs)
end)
Now, in a Server Script, change the playerâs team when that event is fired (you only need this script once, unlike the LocalScript that has to be in each button):
game.ReplicatedStorage.TeamChangeEvent.OnServerEvent:Connect(function(plr, team)
plr.Team = team
--plr: The player that fired the RemoteEvent
--team: The team the player wants to change to
end)
Thank you very much it worked!