How can i make a object have its own debounce

Im making a Quest system right now and i came across a brick wall…

so basically im trying to use touched events with debounces using time().
what im trying to do is have a cooldown for each part.

heres what im trying to achieve

as you can see in the video im touching every part but it has the cooldown so its not printing for each part that is being touched only after 1 second which is the cooldown its printing the part

heres the current code i got

local Time = time()
for index : number, Part in ipairs(AllItems) do
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player and (time() - Time) > 1 then
			Time = time()

Sorry if i said this weirdly i just cant explain it right.

Declare time inside of the loop’s body and it should work as you expect.


I was putting it in the wrong spot instead I put it inside the touched event. Thanks for the help!

1 Like