local ds = game:GetService("DataStoreService"):GetDataStore("SaveName")
game.Players.PlayerAdded:Connect(function(plr)
local key = "user_"..plr.UserId
local money = plr:WaitForChild("PlayerGui"):WaitForChild("Money").TextLabel.Money
local GetSaved
local sucess, warnmsg = pcall(function()
GetSaved = ds:GetAsync(key)
end)
if GetSaved and sucess then
money.Value = GetSaved
print("loaded data")
elseif warnmsg then
warn(warnmsg)
else
money.Value = 10
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local money = plr:WaitForChild("PlayerGui"):WaitForChild("Money").TextLabel.Money
print("saving data for player "..plr.Name)
local sucess, warnmsg = pcall(function()
ds:SetAsync("user_"..plr.UserId, money.Value)
end)
if sucess then
print("saved data")
print(money2.Value)
else
warn(warnmsg)
end
end)
I don’t think that this edited script will fix it but I guess you might as well try. Also do you use multiple datastores with the same name? It seems like you didn’t change the name on line 1.
By the way, keep the game:BindToClose thing I mentioned earlier. You can remove it later once the script is working.
local ds = game:GetService("DataStoreService"):GetDataStore("CoinsDataStore")
Just change it to this for now in case you have other ones with the same name. By the way, are you updating the text after the data loads?