Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I go about adding script generated parts into collision groups?

Asked by 2 years ago

I am experimenting with collision groups. I have set up a barrier which I wish for parts to go through and not allow a player to go through. Here is how I have set it out:

local phys = game:GetService("PhysicsService")

local part = game.Workspace.Parts.DescendantAdded:Connect(function(part)
    if part.Name == "Blocks" then
        part:WaitForChild("Part")
    end
end)

local parts = "parts"

while true do
    phys:SetPartCollisionGroup(part, parts)
end

I will also mention that I am using models which have been cloned which is what "Blocks" is. I assume instance.new parts don't require the if statement.

I notice that I get the error message "Unable to cast value to Object" on line 12.

Answer this question