Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Hey guys, it isnt saving anything. can anyone help me?

Asked by 2 years ago
Edited 2 years ago
local ds = game:GetService("DataStoreService")
local cs = ds:GetDataStore("Cash")

game.Players.PlayerAdded:Connect(function(plr)
    local Cash = plr:WaitForChild("leaderstats"):WaitForChild("Cash")

    local data
    local succ, err = pcall(function()
        data = cs:GetAsync(plr.UserId.."_cash", Cash)

        if succ then
            Cash = data
            print("a")
        end
    end)
end)

game.Players.PlayerRemoving:Connect(function(plr)
    local data = plr.leaderstats.Cash.Value

    local succ, err = pcall(function()
        cs:SetAsync(plr.UserId.."_cash", data)

        if succ then
            print("it worked")
        else
            warn(err)
        end
    end)
end)

please help! it says

nil

when i leave which means nothing or there was an error

0
Replace it with this: FarmIzMyLife 0 — 2y
0
Replace it with this:                                                                                                                         local Players = game:GetService("Players") local DataStoreService = game:GetService("DataStoreService") local Saver = DataStoreService:GetDataStore("SaveLeaderstats") Players.PlayerAdded:Connect(function(player) local Data = nil local success, errormessag FarmIzMyLife 0 — 2y

1 answer

Log in to vote
1
Answered by 2 years ago
Edited 2 years ago

Please use nice words and not ''Guys'' I personally can't stand this. Try to put value behind Cash.

Cash.Value = 0

I see you did this at line 19, try to do this at line 5, 9 and 12 too.

Reply if it doesn't work!

Ad

Answer this question