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

How make an if statement for physical properties?

Asked by 7 years ago
Edited 7 years ago

Hey, I was just wondering how to make an if statement for physical properties, like the part material or color.

if script.Parent.Parent.Door.Material == "Neon" then
    script.Parent.Material = "Neon"
end
0
What you said is a correct way to see if 'script.Parent' has material of 'Neon', is this not what you want? Pretty similar for all other properties. alphawolvess 1784 — 7y
0
I've tried this previously, it doesn't seem to work. Skepticlemon 24 — 7y
0
Oh just noticed that wasn't the script I was using, let me fix it. Skepticlemon 24 — 7y

1 answer

Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
7 years ago

Material values are Enums, not strings. You should check the Enum. You can still set the value with a string for convenience, though.

if script.Parent.Parent.Door.Material == Enum.Material.Neon then
    script.Parent.Material = "Neon"
end
0
It doesn't seem to be working. The door has a script that changes its material when touched, and this should make the egg light up also, but for some reason, it does not do this, it only lights up the door. Skepticlemon 24 — 7y
0
This is the correct answer. If you have a problem in your script context, then ask a better question. cabbler 1942 — 7y
Ad

Answer this question