this didn’t work but it did give me leaderstats
Script in ServerScriptService:
local CashDataStore = game:GetService('DataStoreService'):GetDataStore('Cash')
local TimeBetweenPayout = 20
local PayoutValue = 5
game:GetService('Players').PlayerAdded:Connect(function(player)
local ID = player.UserId
local leaderstats = Instance.new('Folder')
leaderstats.Name = 'leaderstats'
leaderstats.Parent = player
local cash = Instance.new('IntValue')
cash.Name = 'Cash'
local succes, errorMessage = pcall(function()
cash.Value = CashDataStore:GetAsync(ID)
end)
if succes then
print('Data loaded ✓')
else
warn(errorMessage)
end
local cashNow
cash.Changed:Connect(function()
cashNow = cash.Value
end)
while task.wait(TimeBetweenPayout) and player do
cash.Value += PayoutValue
end
local succes, errorMessage = pcall(function()
CashDataStore:UpdateAsync(ID, cashNow)
end)
if succes then
print('Data updated ✓')
else
warn(errorMessage)
end
end)
I wrote that script on mobile device so please watch the output and report any possible issues
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1
Works completely fine for me so idk. The one you provided does not work at all.
Your code is messy and not safe, xpcall()
does not yield
Organization depends on coding style, but you’re correct on the pcall. I changed it.
do you have a leaderstats script?
i tried Sucharec’s script but it didn’t work hmm
Can you show the output after running game with my script?
actually bad topic sorry i think a better topic would be on a script for a daily reward gui but i got a guy i know sorry