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

My datastore script works in studio's play mode but not a live game. any ideas? [closed]

Asked by 5 years ago
local DSService = game:GetService("DataStoreService"):GetDataStore("Currency")
local Saving = 0
wait()
game:BindToClose(function()
    repeat wait() until Saving <= 0
end)

game:GetService("Players").PlayerAdded:Connect(function(plr)
    local leader = Instance.new("Folder")
    leader.Name = "leaderstats"
    leader.Parent = plr 

    local Credits = Instance.new("IntValue")
    Credits.Name = "Credits"
    Credits.Parent = leader

    local Diamonds = Instance.new("IntValue")
    Diamonds.Name = "Diamonds"
    Diamonds.Parent = leader

    local savedData = DSService:GetAsync(plr.UserId.."-Currency")

    if savedData then
        Credits.Value = savedData[1]
        Diamonds.Value = savedData[2]
    else
        local values = {Credits.Value, Diamonds.Value}
        DSService:SetAsync(plr.UserId.."-Currency",values)
    end
end)

game:GetService("Players").PlayerRemoving:Connect(function(plr)
    Saving = Saving + 1
    local ValuesToSave = {plr.leaderstats.Credits.Value, plr.leaderstats.Diamonds.Value}
    DSService:SetAsync(plr.UserId.."-Currency", ValuesToSave)
    Saving = Saving - 1
end)


0
Can you be more precise? how not working on the live game? ItalianEnderman37 7 — 5y
0
Send error. From Output Diltz_3 75 — 5y
0
Give me the error message. terence404 19 — 5y
0
You just posted this a few questions ago. Please refrain from spamming questions. User#21908 42 — 5y
0
sorry jakebball2014 84 — 5y

Closed as Not Constructive by User#20388, GreekGodOfMLG, User#21908, and Operation_Meme

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?