Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Leaderboard datastore not saving error?

Hello! I'm making a model with the robbable bank of alvinblox because many people want it with a script that makes de money save so I'm trying to do it, but as soon as I tested got this error: getasync is not a valid member of datastoreservice. And of course, the leaderboard doesn't show. If someone can fix it, there's the script:

local ds = game:GetService("DataStoreService")
game.Players.PlayerAdded:Connect(function(player)
    local data = ds:GetAsync("player_" .. player.UserId) or 0
    local ls = Instance.new("Folder",player)
    ls.Name = "leaderstats"
    local money = Instance.new("IntValue",ls)
    money.Name = "Money"
    money.Value = data
    local cc = Instance.new("IntValue",player)
    cc.Name = "CashCollected"
    local robbing = Instance.new("BoolValue",player)
    robbing.Name = "Robbing"
    robbing.Value = false
    player.CharacterAdded:Connect(function(char)
        player.Robbing.Value = false
        player.CashCollected.Value = 0
    end)
end)
game.Players.PlayerRemoving:Connect(function(player)
    ds:SetAsync("player_" .. player.UserId, player:WaitForChild("leaderstats").Money.Value)
end)

2 comments

0

NEVER LEARN HOW TO SCRIPT FROM ALVINBLOX!

1 answer

✓ Accepted answer

You're getting this error because you never provided the actual datastore to save it to. This problem can be fixed simply by changing the first line to:

local ds = game:GetService("DataStoreService"):GetDataStore("MoneyDS")

If my answer solved your problem, please remember to mark it as correct!

P.S. AlvinBlox is not a good way to learn to script. He just shows you the code without telling you what it really means, so you never actually learn to script.

This discussion is preserved as it was. New answers, comments, and votes are closed.