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

DataStore won't work... Can anybody help with my script?

Asked by
Discern 1007 Moderation Voter
10 years ago

No data is being loaded, and I'm not even sure if the data is being saved.

No output.

The Strength is popping up in the leaderboard, but its value is always 0, even if I tried to save the data.

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

game.Players.PlayerAdded:connect(function(player)
    local l = Instance.new("IntValue", player)
    l.Name = "leaderstats"
    local s = Instance.new("IntValue", l)
    s.Name = "Strength"
    player.leaderstats.Strength.Value = DataStore:GetAsync("Strength_" ..player.Name.. "")
    player.leaderstats.Strength.Changed:connect(function(newValue)
        DataStore:SetAsync("Strength_" ..player.Name.. "", newValue)
    end)
end)

Answer this question