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

Datastore, no errors in output. The API is enabled, but doesn't work. Why? [closed]

Asked by 6 years ago

I just started working on datastores as I wanted to learn. I wrote up a code, and enabled API services. There are no errors in output, but when I change my values, they don't save can anyone help?

local DSService = game:GetService('DataStoreService'):GetDataStore('DataStore')
game.Players.PlayerAdded:connect(function(plr)

    local uniquekey = 'id-'..plr.userId
    local leaderstats = Instance.new('IntValue', plr)
    local savevalue =  Instance.new('IntValue')
    leaderstats.Name = 'leaderstats'
    savevalue.Parent = leaderstats
    savevalue.Name = 'Cash'


    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.Cash.Value}
DSService:SetAsync(uniquekey, Savetable)    


end)
0
How are you changing the values? DinozCreates 1070 — 6y
0
If its being done locally, or you're manually doing it then thats the issue. Has to be changed server side. DinozCreates 1070 — 6y
0
Read the guidelines before asking a question, specifically "Attempts should be your own work. Don't take a free model and expect us to fix it." Even if it is not from a free model, it isn't your own work. https://scriptinghelpers.org/help/community-guidelines This is a script copied from alvinbloxx: https://www.youtube.com/watch?v=tOOS9lMIYes User#19524 175 — 6y

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?