So while I was exploring loops in scripting, I came across an issue I could not resolve. I was trying to make a GUI that made all parts in workspace can-collide off. This did not work. The script was something like this: (This was on a serverScript)
for i,v in pairs(workspace:GeChildren()) do
if v.CanCollide then
v.CanCollide = false
end
end
I got an error. It was detecting a folder that I had put into workspace and obviously, a folder doesn’t have the canCollide property. I was trying to see if the property existed in the part but I think the script thought that I wanted to see if it was true or false. I still am not sure how I could see if an instance has a property so If you guys have any tips on how to, please share.
Yes, basepart is every part type
pcall is not necessarily lazy, it just avoids errors. I find it useful when altering Transparency in a character since both Decal and BasePart have Transparency
(also it can hide stack trace if your pcall errors (even though you can print the error message))