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

Issue with logical operators?

Asked by 10 years ago

if hit.Name == "Log" and hit.Planks and hit.Mesh == nil then

this line says its incorrect how would I get an if statement to check multiple things?

1 answer

Log in to vote
1
Answered by 10 years ago

You could write it like this:

if hit.Name == "Log" --If the hit object's name is "Log"
and hit:FindFirstChild("Planks") --If the hit object has planks
and (not hit:FindFirstChild("Mesh")) then --If the hit object doesn't have a Mesh
    --Do stuff
end

Note: The if statement can be all on one line like this: if hit.Name == "Log" and hit:FindFirstChild("Planks") and (not hit:FindFirstChild("Mesh")) then

Ad

Answer this question