Sorry for my title, I couldn't change it. --Server Script--
local ds = game:GetService("DataStoreService"):GetDataStore("CashStats")
local debounce = false
game:GetService("Players").PlayerAdded:Connect(function(plr)
local key = "ID-"..plr.UserId
local data = plr.leaderstats.Cash.Value
local sucess, errorm = pcall(function()
ds:SetAsync(key, data)
end)
script.Parent.MouseButton1Click:Connect(function() --When player click on the save button
if not debounce then
debounce = true
if sucess then -- If it's successful
print("Data Saved!")
else -- If not
print("There was a problem while saving your data!")
end
wait(30)
debounce = false
end
end)
end)
Please help me. Thx for reading! #SaveButton

4 comments
what does this refer to: script.Parent.MouseButton1Click:Connect(function()?
I was going to solve this but not after I read the prints..
Sorry for my print..
and this: script.Parent.MouseButton1Click:Connect(function() refer to when player click the save button