I’ve added a debounce, but it still seems to have the same issue.
for _, Cehckp in pairs(checkpointsTable) do
Cehckp.Touched:Connect(function(plr)
if debounce == true then
DataStore:SetAsync(getUserIdFromUsername(plr.Parent) .."-stage",Cehckp.Name)
if plr and plr.Parent then
debounce = false
print(Cehckp.Name.. " " .. plr.Parent.Name)
wait(5)
debounce = true
end
end
end)
end
No, the issue is definitely not the debounce. Even if you fix the debounce, the problem will still exist, which is that you’re writing to a DataStore every time a part is touched.
There are limitations to DataStores that you need to be mindful of and this code will not respect those limits. What you should be doing is saving data when a player leaves, not when they touch the checkpoint. The checkpoint should only change the stage they’re on but it should not do any saving itself.
As it has been said already, the issue is not that Roblox is ignoring your debounce.
The userid that is in the warning message (73502) leads to this profile Instance - Roblox. They have the name “Instance”, it seems like you aren’t actually checking if what is hit is a player in your code.
Before you call SetAsync check if plr is actually a part of a players character, you can do this with the players service and a bit of code like this:
local player = game:GetService("Players"):GetPlayerFromCharacter(plr.Parent)
if player then
-- Do datastore and debounce things
end
Hey, I changed the system to save it on a StringValue and when on leave it checks that and does the changes. I am getting this error though:
104: Cannot store Instance in data store. Data stores can only accept valid UTF-8 characters.
As far as I am aware, this still saves the same.
Old:
What is the value of StageNumber when this error occurs? I don’t have enough information to help you. It would also be helpful if you posted your code into the thread as code boxes instead of images so people here who may help you with this problem can actually copy parts of the code to work with.
add debounce after if statement.
Because it sets datastore then check plr.parent
then debounce turn into false.
Also you did a mistake in :SetAsync() you put plr.Parent instead of plr.Parent.Name
I fixed everything in this script:
Show
for _, Cehckp in pairs(checkpointsTable) do
Cehckp.Touched:Connect(function(plr)
if debounce == true then -- check if db equals true
debounce = false -- sets db to false then call database function
DataStore:SetAsync(getUserIdFromUsername(plr.Parent.Name) .."-stage",Cehckp.Name)
if plr and plr.Parent then
print(Cehckp.Name.. " " .. plr.Parent.Name)
wait(5)
debounce = true
end
end
end)
end