What’s the problem?
I’ve created a script (some people helped me) and the Datastore isn’t working. It says that the value has been saved. Yet, when I rejoin the server (in-studio) it still shows the default amount. No errors are appearing in the Output either. Even the print that states if it’s an error doesn’t print, nor the success print. Anyways here’s the script.
local DSS = game:GetService("DataStoreService")
local Datastore = DSS:GetDataStore("TestDataStore")
game.Players.PlayerAdded:Connect(function(plr)
local CurrencyData = Instance.new("Folder")
CurrencyData.Name = "CurrencyData"
CurrencyData.Parent = plr
local Balance = Instance.new("NumberValue")
Balance.Name = "Balance"
Balance.Parent = CurrencyData
Balance.Value = 1000
local success, currentbalance = pcall(function()
return Datastore:GetAsync(plr.UserId .. "-balance")
end)
if success then
if currentbalance then
Balance.Value = currentbalance
end
print("Success getting data!")
else
print("Error getting data!")
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, err = pcall(function()
Datastore:SetAsync(plr.UserId .. "-balance", plr.CurrencyData.Balance.Value)
end)
if success then
print("Success saving data!")
else
print("Error saving data!")
end
end)
**Status**
Solution: No