I have a game that I am working on. It has a paycheck system that uses an int value in the leaderboard script. The int value sets the amount of pay with a script. Here is the problem though, The script that sets the amount doesn't change the value. I use teams to get the value. I am new to scripting
Leaderboard (Script) (With data saving):
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("CashSaveSystem")
game.Players.PlayerAdded:connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local cash = Instance.new("IntValue", folder)
cash.Name = "Money"
cash.Value = ds1:GetAsync(plr.UserId) or 500
ds1:SetAsync(plr.UserId, cash.Value)
cash.Changed:connect(function()
ds1:SetAsync(plr.UserId, cash.Value)
end)
while true do
wait(60)
cash.Value = cash.Value + script.PayCheck.Value
end
end)
Pay Check setting script (Local)
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local paycheck = game.Workspace.Leaderboard.PayCheck.Value
local teams = game:GetService("Teams")
if player.Team == teams.Citizen then
paycheck = 120
end
if player.Team == teams.Criminal then
paycheck = 150
end
if player.Team == teams.Inmate then
paycheck = 0
end
if player.Team == teams.Police then
paycheck = 200
end
if player.Team == teams.HeavyGunDealer then
paycheck = 225
end
if player.Team == teams.GunDealer then
paycheck = 165
end
if player.Team == teams.AdminOnDuty then
paycheck = 10000
end

2 comments
I'd assume this is because you are using a local script, since that only changes the stats locally, not globally. Maybe try using a regular script? (Corrected)
Use remote function or event.