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

How would I make this work?

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!

1 comment

0

And yes, it has a click detector.

1 answer

✓ Accepted answer

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!

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