thegamer_guy
Coder
This script is supposed to pay money to the leaderboard value when a player is on a certain team, but it's not working.
Code:
local Teams = game:GetService("Teams")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local jobConfig = {
["McWilliam's Worker"] = 650,
["Another Job"] = 500,
["Yet Another Job"] = 750,
}
local paymentInterval = 300 -- 5 minutes
local paymentNotificationEvent = ReplicatedStorage:WaitForChild("PaymentNotification")
-- Function to pay players in the jobs
local function payPlayers()
for teamName, paymentAmount in pairs(jobConfig) do -- Loop through each job
local team = Teams:FindFirstChild(teamName)
if team then -- If the team exists
for _, player in pairs(team:GetPlayers()) do
local leaderstats = player:FindFirstChild("leaderstats")
local money = leaderstats and leaderstats:FindFirstChild("Money")
if money then
money.Value = money.Value + paymentAmount -- Add money to the player
print("Paid " .. player.Name .. " $" .. paymentAmount)
paymentNotificationEvent:FireClient(player, paymentAmount) -- Send notification to player
else
print("Money value not found for player: " .. player.Name)
end
end
else
print("Team " .. teamName .. " not found")
end
end
end
-- Repeat the payPlayers function every 5 minutes
while true do
wait(paymentInterval)
payPlayers()
end