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

How would I make this work?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I'm trying to make a part go from transparency = 0 to transparency = 1 onClicked.

For some reason it's not working, idk how to fix it.

local Part = script.Parent

function onClicked(playerWhoClicked)
    Part.Transparency > 0 do
        Part.Transparency = Part.Transparency - 1
    wait(1)
    end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Any help would be greatly appreciated!

0
And yes, it has a click detector. DataFlame 24 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

You're not using a "check" right. Use an if statement!

Here's where you did Lua wrong,

Part.Transparency > 0 do

What you should be doing is,

if Part.Transparency > 0 then

This means your code should look like this,

local Part = script.Parent

function onClicked(playerWhoClicked)
    if Part.Transparency > 0 then
        Part.Transparency = Part.Transparency - 1
    wait(1)
    end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Good Luck!

Ad

Answer this question