So That’s where I need to see what team the player is on where I am having issues with, That’s what I need finding what I put before that as it needs to have the team at all times.
Speaking with the Founder He wants it to be Remotes so how it is just needing that Team line to be fixed. Ik I want to change it but I work to Clients use’s and needs.
I agree with some of the other posts here, the easiest way to do this would likely be to just loop through all active Players in-game, and send the appropriate amount of money to each Player based on their current team.
One of the main differences in my snippet below to your initial script is that I loop through the set of Players in-game once per payment cycle (every 10 seconds), and fire the MoneyEvent for each individual Player. This allows you to send the appropriate amount of money (pay) to a Player based on their team alone. (I’m using RemoteEvent:FireClient(plr, moneyAmt) instead of RemoteEvent:FireAllClients(moneyAmt).
--Setup variables
--Assign MoneyEvent to a variable... etc.
--Define the amount to pay players on each team
local residentPayAmt = game.Workspace.Jobs.ResidentPayment.Amount.Value
local DPDPayAmt = game.Workspace.Jobs.DPDPayment.Amount.Value
--Define the name of each possible team for payment
local RESIDENT_TEAM = "Resident"
local DPD_TEAM = "DPD"
--The length of time to wait in-between paying players
local PAY_WAIT_TIME = 10
--Core Payment loop
while true do
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
--Check if the Player is on a team
if plr.Team then
--Send the Resident Pay amount to Players on the Resident Team
if plr.Team.Name == RESIDENT_TEAM then
MoneyEvent:FireClient(plr, residentPayAmt)
--Send the DPD Pay amount to Players on the DPD Team
elseif plr.Team.Name == DPD_TEAM then
MoneyEvent:FireClient(plr, DPDPayAmt)
end
--Add additional teams for payment as needed
end
end
task.wait(PAY_WAIT_TIME)
end
One parting note based on the discussion here:
It’s true that you’d probably want to store the amount of money each player has on the server independent of the client. If you rely solely on the client for actions such as purchases, it could be very easy to exploit as you’d have no way to verify the actual amount of money the Player should have. I’m assuming the person you’re working for wants remote communication to update GUI elements locally for each Player.