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

Why does this datastore script not work? Do I need an updated one? [closed]

Asked by 5 years ago
Edited 5 years ago

Heres the script...

local DSService = game:GetService('DataStoreService'):GetDataStore('potomojokolonotofghdghdglsirityru')
game.Players.PlayerAdded:connect(function(plr)
    -- Define variables
    local uniquekey = 'id-'..plr.userId
    local leaderstats = Instance.new('IntValue', plr)
    local savevalue =  Instance.new('IntValue')
    leaderstats.Name = 'leaderstats'
    savevalue.Parent = leaderstats
    savevalue.Name = 'Level'

    -- GetAsync
    local GetSaved = DSService:GetAsync(uniquekey)
    if GetSaved then
        savevalue.Value = GetSaved[1]
    else
        local NumbersForSaving = {savevalue.Value}
        DSService:SetAsync(uniquekey, NumbersForSaving)
    end
end)

game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local Savetable = {plr.leaderstats.Level.Value}
DSService:SetAsync(uniquekey, Savetable)    


end)
0
:connect is deprecated, or not recommended. You should use:Connect since :connect might get removed saSlol2436 716 — 5y
0
Oh ok i'll try that. protectiverobos -50 — 5y
0
This is alvinbloxx’s code. User#19524 175 — 5y
0
Don’t come on this site with code that isn’t yours and expect it to be fixed. User#19524 175 — 5y

Closed as Not Constructive by User#19524

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?