local DataStoreService = game:GetService("DataStoreService")
local MoneyDataStore = DataStoreService:GetDataStore("MoneyDataStore")
local player = game:GetService('Players')
local Money = 0
local debounce
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local MoneyCash = Instance.new("IntValue")
MoneyCash.Name = "MoneyCash"
MoneyCash.Value = 0``
MoneyCash.Parent = leaderstats
local success, errormessage = pcall(function()
Money = MoneyDataStore:GetAsync(player.UserId.."-Cash")
MoneyCash.Value = MoneyDataStore:GetAsync(player.UserId.."-Cash")
end)
if success then
Money = MoneyCash.Value
else
print("Error something whent bad")
warn('error with setting 1 '..errormessage)
end
game.Workspace.Touchedpart.Touched:Connect(function(p)
if p.Parent:FindFirstChild("Humanoid") then
if not debounce then
debounce = true
Money = Money + 1
MoneyCash.Value = Money
print(MoneyCash.Value)
wait(0.4)
debounce = false
end
end
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormassage = pcall(function()
MoneyDataStore:GetAsync(player.UserId.."-Cash",player.leaderstats.MoneyCash.Value)
end)
if success then
print(player.leaderstats.MoneyCash.Value)
print("Data saved!")
else
print("there was an error when saving data")
warn('error with saving 2 '..errormassage)
end
end)
it says Data saved! on output but it doesent save any help

1 comment
BTW this is all of the code