Need help with debouncing a coin script

When a cloned coin is picked up it runs a counter and then determines when a chest will spawn. I’ve made the coins transparency to 1 while the coin sound plays and then clone:Destroy() when ended.

I’m thinking while the coin is transparent my counter is still picking up the coin. I need a way to tell it to ignore the coin it’s already counted. A wait() simply won’t work as if a new chest is picked up while waiting it won’t be counted. Any ideas?

I picked up 1 coin!

		if not clone:GetAttribute("Touched")then
			clone:SetAttribute("Touched", true)
			if counter ~= 0 then
				counter = counter - 1 -- still Hitting multiple times
				counter = 20
				print("counter is reset to 20")
		clone:SetAttribute("Touched", false)

Somewhere you could put

 if Coin.Transparency ~= 0 then

That was a really excellent suggestion. Tyvm. Solved!

Make sure to make the reply that gave the solution as the solution, not just the response :slight_smile:

Thought I did, the green tick on Solution is ticked. :smiley:

You ticked your own reply - which was saying that my reply was the solution, as the solution, instead of the reply I put :slight_smile:

Oops, sorry about that. fixed!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.