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)
COMMUNITY QUESTION
My datastore script works in studio's play mode but not a live game. any ideas?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
Can you be more precise? how not working on the live game?
Send error. From Output
Give me the error message.
You just posted this a few questions ago. Please refrain from spamming questions.
sorry