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

If statment to check property?

Asked by 4 years ago

Hi I am trying to use an if statement to check the property of a object. I am a beginner and the following code does not work if game.Workspace.Lamp.Material = Enum.Material.Glass do Game.Workspace.Lamp.Material = Enum.Material.Neon else Game.Workspace.Lamp.Material = Enum.Material.Neon endend end)

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

In conditional statements, you use '==' instead of '=' to compare! :D So the beginning of your code would look like this:

if game.Workspace.Lamp.Material == Enum.Material.Glass then
    Game.Workspace.Lamp.Material = Enum.Material.Neon
    print("Material set.")
end

(written from my head but it should work)

Pro tip: use 'Print' to print to the output window, good for testing whether certain parts of scripts are working.

Hope this helps, Merry Christmas!

Ad

Answer this question