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

If statements for physical properties?

Asked by 7 years ago

Hey, I was just curious on how to make an if statement for a physical property. I have a door, when touched it changes material, basically, when this happens, the egg is suppose to detect it and change it's material also, but this doesn't happen. Any help, please?

if script.Parent.Parent.Portal.Material == Enum.Material.Neon then
    script.Parent.Material = "Neon"
end
0
Are you sure that script.Parent is the thing you want? Is this in a touch function? RubenKan 3615 — 7y
0
Yes. Skepticlemon 24 — 7y
0
When the portal/door is touched, it should light up both parent of the script and the door. Skepticlemon 24 — 7y

1 answer

Log in to vote
0
Answered by
glinary 19
7 years ago

Not really familiar with your file explorer so here it goes:

local door = script.Parent  --idk where your door is located
local egg = script.Parent.Parent -- just put where your egg is located

door.Touched:connect(function(hit)
    humanoid = hit.Parent:FindFirstChild("Humanoid")
        if humanoid then -- this checks if there's a humanoid to what hits the door
           egg.Material = Enum.Material.Neon -- this changes the material of egg to neon
        end
end)
Ad

Answer this question