Here is the code I added to mine so the script would create the collision groups automatically and assign the parts to them. I put this in the CarHandler script near the beginning just after the Cooldown function:
function getGroupId(name)
-- GetCollisionGroupId will throw error if it does not exist
local ok, groupId = pcall(physicsService.GetCollisionGroupId, physicsService, name)
return ok and groupId or nil
end
local checkforgroup
checkforgroup = getGroupId("Character")
if checkforgroup == nil then physicsService:CreateCollisionGroup("Character") end
checkforgroup = getGroupId("CarBody")
if checkforgroup == nil then physicsService:CreateCollisionGroup("CarBody") end
checkforgroup = getGroupId("CarWheel")
if checkforgroup == nil then physicsService:CreateCollisionGroup("CarWheel") end
physicsService:CollisionGroupSetCollidable("Character", "CarBody", false)
physicsService:CollisionGroupSetCollidable("CarWheel", "CarBody", false)
for _,part in ipairs(script.Parent:GetDescendants()) do
if (part:IsA("BasePart")) then
if part.Name == "PhysicalWheel" then physicsService:SetPartCollisionGroup(part, "CarWheel") end
if part.Name == "Body" then physicsService:SetPartCollisionGroup(part, "CarBody") end
end
end
This will allow you to export the model and import it into another game and not have to manually recreate the groups and assign the parts, assuming you labeled the parts exactly the same and the game doesn’t have the groups already in which case you may have some overlap issues. This worked for me.
(edit: I misunderstood how the check function worked, I’ve updated this script clip to work properly now if the group already exists)