How would I make a debounce that only happens once and NEVER happens again. Even after the player left and rejoined? like Setting your humanoid body depth scale and width scale to 0.1. After that your data saves so you never use it again!
You might want to save this data using DataStoreService. Here's some code that would add to a table when they join if they should have it happen to them or not.
local DSS = game:GetService('DataStoreService') local debounce = DSS:GetDataStore('debounceStore') local debounceUsers = {} function getData(plr) return debounce:GetAsync('debounce_'..plr.UserId) end game.Players.PlayerAdded:connect(function(plr) local saved = pcall(getData) if saved then debounceUsers[plr.UserId] = true else debounceUsers[plr.UserId] = false end end)
This code would get the DataStore and when they join, check if they're in the DataStore, then set the key as their userID and set the value in the table as if they are in the DataStore. The value in the table is true if they're in the DataStore and false if they're not.
If you wanted to check if they were in the table, you'd do this in the same script:
function inDebounce(plr) return debounceUsers[plr.UserId] end game.Players.PlayerAdded:connect(function(plr) wait(1)--Allow for loading if inDebounce(plr) then print'This user is in the datastore!' else print'This user is NOT in the datastore!' end end)
That code would check their key in the table to determine if they're in the datastore.
To save that data, you would use this
--Whatever code determines if they should be added above ^ --Define plr in your script if they should be added. ^ local DSS = game:GetService('DataStoreService') local debounce = DSS:GetDataStore('debounceStore') function addPlayer(plr) debounce:SetAsync('debounce_'..plr.UserId, true) end pcall(addPlayer(plr))
You should use pcalls incase your script errors out from DataStore limits.
Hope I helped! Accept my answer below if I answered your question, and add comments if you need help!