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

How do I avoid model collision with itself?

I have a rocket that when something touches the tip, it explodes. However, when I drop it, it explodes because it collided with itself. How do I tell it not to explode if they collide with a part of a rocket? here's the script:

local model = script.Parent.Parent
model.PrimaryPart = model.Base
model.Base.Fire.Enabled = true

local explosionPart = script.Parent
while true do 
	wait()
	script.Parent.Parent:SetPrimaryPartCFrame(script.Parent.Parent.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0,.1,0))
script.Parent.Touched:connect(function(hit)
   if hit:IsDescendantOf(script.Parent.Parent) == false then
      	local explosion = Instance.new("Explosion", game.Workspace)
explosion.Position = explosionPart.Position
explosionPart.Parent:Destroy()
 

end
end)
end

1 answer

So there is something called "CollisionGroups" and they can disable collision between another collison group or itself. It kinda goes like this:

local PhysicsService = game:GetService("PhysicsService") --This gets the service

PhysicsService:CreateCollisonGroup("[name]") --Creates a collisiongroup

PhysicsService:CollisonGroupSetCollidable("[group]", "[group]", [true/false]) --Defines collison properties between 2 groups

PhysicsService:SetPartCollisonGroup(part, group) --adds a part to the collision group

All you would need to do is make sure the rocket parts are in a collisiongroup and add the rocket to that group when it spawns.

Hope this helped! You can also find a post about this on the devforums, but I forgot the link.

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