Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is ClickDetector not deleting?

(Ignore me not using a for loop)

local C = script.Parent
local function onMouseClick(Player)
	while wait(0.1) do
		C.Parent.Transparency = 0
		wait(0.1)
		C.Parent.Transparency = 0.1
		wait(0.1)
		C.Parent.Transparency = 0.2
		wait(0.1)
		C.Parent.Transparency = 0.3
		wait(0.1)
		C.Parent.Transparency = 0.4
		wait(0.1)
		C.Parent.Transparency = 0.5
		wait(0.1)
		C.Parent.Transparency = 0.6
		wait(0.1)
		C.Parent.Transparency = 0.7
		wait(0.1)
		C.Parent.Transparency = 0.8
		wait(0.1)
		C.Parent.Transparency = 0.9
		wait(0.1)
		C.Parent.Transparency = 1.0
		wait(0.1)
		C.Parent.Transparency = 0.9
		wait(0.1)
		C.Parent.Transparency = 0.8
		wait(0.1)
		C.Parent.Transparency = 0.7
		wait(0.1)
		C.Parent.Transparency = 0.6
		wait(0.1)
		C.Parent.Transparency = 0.5
		wait(0.1)
		C.Parent.Transparency = 0.4
		wait(0.1)
		C.Parent.Transparency = 0.3
		wait(0.1)
		C.Parent.Transparency = 0.2
		wait(0.1)
		C.Parent.Transparency = 0.1
		wait(0.1)
		C.Parent.Transparency = 0
	end
	if C.Parent.Transparency > 0.1 then C:remove()
	end
end
C.MouseClick:connect(onMouseClick)

I was wondering why this doesn't get rid of the ClickDetector. I want to do this so that they can't click the part again and mess up the Transparency.

2 answers

Because you're setting C.Parent.Transparency to 0 and asking if the transparency is greater than .1 in order to delete it.

Maybe because anything outside of your while wait() loop will not function...? No need for it.

This discussion is preserved as it was. New answers, comments, and votes are closed.