One method I use is this also yuan is like a int value
local YuanDB = false -- true if a thread is in the process of saving local YuanWaiting = false -- true if a thread is waiting for a chance to save Yuan.Changed:Connect(function() if YuanWaiting then return end -- this function is being run and another thread is waiting to run YuanWaiting = true while YuanDB do wait(1) end YuanWaiting = false YuanDB = true local success = pcall(function() datast1:SetAsync(plr.UserId, Yuan.Value) end) if success then print('Data has been saved') else print('Data failed to save. Error message:", msg') end wait(60) --How long it gonna take to save YuanDB = false local YuanDB = false -- true if a thread is in the process of saving local YuanWaiting = false -- true if a thread is waiting for a chance to save Yuan.Changed:Connect(function() if YuanWaiting then return end -- this function is being run and another thread is waiting to run YuanWaiting = true while YuanDB do wait(1) end YuanWaiting = false YuanDB = true local success = pcall(function() datast1:SetAsync(plr.UserId, Yuan.Value) end) if success then print('Data has been saved') else print('Data failed to save. Error message:", msg') end wait(60) --How long it gonna take to save YuanDB = false
or this simple method
while wait(60) do Yuan:SetAsync