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

if child.CanCollide then is not working as I thought?

for index, child in pairs(wendigoParts) do
	print(child.Name)
	if child.CanCollide then
		print(child.Name, " Can Collide")
		PhysicsService:SetPartCollisionGroup(child, wendigoGroup)
	end
end

The script is always stopping on the

if child.CanCollide then

It is stopping when it runs into something that does not have the CanCollide inside of it. I thought the if CanCollide ment if it has the CanCollide feature the next line runs?

2 comments

0

Try using if child:IsA("BasePart") and child.CanCollide then

0

if child.CanCollide actually checks if it is true, not if it is a property.

1 answer

✓ Accepted answer

Try this code:

for index, child in pairs(wendigoParts) do
    print(child.Name)
    if child:IsA("BasePart") and child.CanCollide then
        print(child.Name, " Can Collide")
        PhysicsService:SetPartCollisionGroup(child, wendigoGroup)
    end
end

Changes that I made: (Thanks to @NathanTheDeveloper): Tested to see if child was a BasePart and if it had true for CanCollide

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