Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why is ClickDetector not deleting?

Asked by 10 years ago

(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

Log in to vote
1
Answered by
Vathriel 510 Moderation Voter
10 years ago

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

Ad
Log in to vote
0
Answered by 10 years ago

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

Answer this question