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

If statment to check property?

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

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!

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