Need help with a simple script

I’m trying to learn to script and I’m trying to make a part invisible if it’s visible (as shown below)

if workspace.Part.Visible = true then
	workspace.Part.Visible = false

It just doesn’t seem to work.Capture
(also note that the only code in the script is what was shown above)
Can someone help me?

1 Like

First of all you need to change the localscript to a normal script. And visible is not a property of a BasePart, i think you mean Transparency.


an if statement requires an == instead of an = do

local Part = workspace:Part
if Part.Transparency == 0 then
part.Transparency = 1

(What @Voltiqs said is true, I was about to forget lol)
1 Like

Oh okay. I’ll try it.

I believe your error lies in the fact that you’re not comparing values.

workspace.Part.Visible = true

This statement simply sets the Part’s Visible property to true, but you want to be comparing the value of the Visible property.

Instead, you’ll want to use == instead of just =. One equal sign will assign something to a new value, but two equal signs will return a true or false reply.

workspace.Part.Visible == true

This will check if Part.Visible is actually true. And if it is, then this will return true to your if statement, and then it will run the code within your if statement.

1 Like

Thanks! It works now. :slight_smile:

1 Like