Debounce isn't working

im trying to make it so when u touch a part it doesn’t do a touch event multiple times

i researched and adding a debounce is supposly supposed to work

so when i added one, the debounce isn’t working.

de = false

part.Hit1.Touched:Connect(function(hit)
		if de then return end
		
		if hit.Parent:FindFirstChild("Humanoid") then
			de = true
			hit.Parent.Humanoid:TakeDamage(100)

			plr.Stats.XP.Value += 100
		end
		
		wait(5)
		de = false
	end)
1 Like

wdym its not working whats happening instead?

maybe you could do this instead:

de = false

part.Hit1.Touched:Connect(function(hit)
		if de then return end
		
		if hit.Parent:FindFirstChild("Humanoid") then
			de = true
			hit.Parent.Humanoid:TakeDamage(100)

			plr.Stats.XP.Value += 100
		
		    wait(5)
		    de = false

		end
	end)
1 Like

nvm i fixed it, thanks for ur help though

1 Like

What was the problem? was it a simple fix?

1 Like