How to make IF Players.Team = true the cash value increases by a certain amount?

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)
1 Like

Thank you very much it worked!

1 Like