Disappearing block script won't work (SOLVED)

I know I’ve probably looked over some stupid issue, and it’s glaringly obvious to everyone else, but I can’t seem to find what’s making this break.

script:

local Block = script.parent
local debounce = false

local function disappear()
	if debounce then return end
	debounce = true
	
	local count = 0
	while count < 1 do
		Block.Transparency = count + 0.1
		wait(0.05)
	end
	if Block.Transparency == 1 then
		Block.CanCollide = false
	end
	wait(2)
	Block.CanCollide = true
	Block.Transparency = 0
	
	debounce = false
end

Block.Touched:Connect(disappear)

Put

if not debounce then return end

You’re basically saying if debounce is true then return end. But it’s impossible since you set it to false.

1 Like

God I’m blind, thank you for pointing this out.

Edit - The debounce is actually fine, it was a problem with the count never changing.

You never change the value of count in your while loop, which will cause the loop to run forever with no change.

Ah, no actually, I just forgot to put “count = Block.Transparency”, I just took a glance at another script I’ve done.