I am new to scripting and i tried to make a simple colour changing tile script with a debounce but it doesnt work.

local part = script.Parent
local debounce = false

script.Parent.Touched:Connect(function(hit)
	if hit.Parent then
		if not debounce then
			debounce = true
			part.Material = "Neon"
			part.BrickColor = BrickColor.Random()
			debounce =  false
		end
	end
end)

I looked at the wiki to try learn debounce but i found it a bit confusing. Any help would do explaining debounce and how to fix my script

2 comments

0

The debounce isn’t performing an actual preventive instruction. Add a wait(timeNumber) before calling debounce = false

0

Thanks Feahren! It worked