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

Can you have Logical operator in FindFirstChild such as or?

Can you not have logical operator such as or in FindfirstChild or am I just missing a step?

Local bloon = game.workspace:findFirstChild("Part1"or"Part2") -- reads part1 but when i have only part2 its nil

if bloon then
print("Part exists")

else

print("nil")
end

1 comment

0

As far as I know, that's not possible; it has to be either 'nil or "TEXT"', I believe, b/c both are strings & not nil values.

1 answer

✓ Accepted answer

You're close.

print(nil or 1)--// 1

print(1 or nil)--// 1

print(1 or 1)--// 1

print(nil or nil)--// nil

"Part1"or"Part2" results to "Part1". To fix this, use or with two FindFirstChilds.

local bloon = workspace:FindFirstChild("Part1")or workspace:FindFirstChild("Part2")

This article should explain more.

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