Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Am I using 'or' properly?

Asked by 9 days ago

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 366 — 9d

1 answer

Log in to vote
1
Answered by 9 days ago
Edited 9 days 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

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
0
You need IsA to check if it's a basepart like by d[i]:IsA("BasePart"), not just checking ClassName. hiimgoodpack 1845 — 9d
0
My bad, I forgot since its been a while ;d YTRaulByte 254 — 9d
Ad

Answer this question