Still have questions? Join our Discord server and get real time help.
0

# 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

0
To post code click on the <>. Mr_Unlucky 988 — 3mo

1
Edited 3 months ago

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


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

0
You need IsA to check if it's a basepart like by d[i]:IsA("BasePart"), not just checking ClassName. hiimgoodpack 1851 — 3mo
0
My bad, I forgot since its been a while ;d YTRaulByte 259 — 3mo