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

Am I using 'or' properly?

Okay so I want my tool to become cancollide = false when it's equipped. In the equipped function, I have...

local d = tool:GetChildren()

for i=1, #d do

if (d[i].ClassName == "Part" or "MeshPart" or "UnionOperation") then

d[i].CanCollide = false

end

end

Also, How do I post code here? i haven't been since the stackedit update thing

1 comment

0

To post code click on the <>.

1 answer

✓ Accepted answer

no you are not using 'or' properly

You would need to repeat the first half of the comparison: NO:

if x == 5 or 3 or 2 then

AS IT IS:

if (x == 5) or (? == 3) or (? == 2) then

YES:

if x == 5 or x == 3 or x == 2 then

OR IN YOUR CASE:

if (d[i].ClassName == “Part” or d[i].ClassName == “MeshPart” or d[i].ClassName == “UnionOperation”) then

Which could also be shortened to:

if (d[i].ClassName == "BasePart") then

2 comments

0

You need IsA to check if it's a basepart like by d[i]:IsA("BasePart"), not just checking ClassName.

0

My bad, I forgot since its been a while ;d

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