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

Want to data save for my scoring system, but it doesn't work?

Asked by 7 years ago

I have tried so many data save methods and NONE of them work for me. Hopefully you guys will be able to help.

GemsStore = game:GetService("DataStoreService"):GetDataStore("DataStore")


game.Players.PlayerAdded:connect(function(plr)
    local stats = Instance.new('Folder', plr)
    stats.Name = 'leaderstats'
    local Gems = Instance.new('IntValue', stats)
    Gems.Name = 'Gems'
    Gems.Value = GemsStore:GetAsync(plr.UserId) or 0

    if GemsStore:GetAsync("Points_"..plr.Name) ~= nil then
        Gems.Value = GemsStore:GetAsync("Points "..plr.Name)
    else
        Gems.Value = 0
        end

    Gems.Changed:connect(function(Val)
        GemsStore:SetAsync("Points "..plr.Name, Val)

end)
end)

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Should work now. You had SetAsync and GetAsync with different names liek 'points_name' or 'points name' etc. Make sure in your configuration in your place you should have Save API enabled.


GemsStore = game:GetService("DataStoreService"):GetDataStore("DataStore") game.Players.PlayerAdded:connect(function(plr) local stats = Instance.new('Folder', plr) stats.Name = 'leaderstats' local Gems = Instance.new('IntValue', stats) Gems.Name = 'Gems' Gems.Value = GemsStore:GetAsync("Points_"..plr.Name) or 0 if GemsStore:GetAsync("Points_"..plr.Name) ~= nil then Gems.Value = GemsStore:GetAsync("Points_"..plr.Name) else Gems.Value = 0 end Gems.Changed:connect(function(Val) GemsStore:SetAsync("Points_"..plr.Name, Val) end) end)
Ad

Answer this question