Car crash system not working

Hello there, I’m making a car crash physics and for some reason when a part breaks it breaks every other part in the car.

Here is the script:

local Matar = script.Parent:WaitForChild('Motor')
local Crash = false
local NumberOfHit = 0
local RS = game:GetService('ReplicatedStorage')
local RUN_EVENT = RS:FindFirstChild('RUN_EVENT')
local BODY = script.Parent
local CRASHSOUND = script:FindFirstChild('Crash')

Matar.Touched:Connect(function(hit)
	--print(hit)
	--print(hit.Name)
	if hit.Parent == hit:FindFirstAncestor("Body") or hit.Parent == hit:FindFirstAncestor("Wheels") or hit.Name == "Baseplate" then
		--print('NO EXPLOSION *SAD CAT NOISE :CCCCCCCCCCC*')
	elseif Matar.Velocity.Magnitude >= 100 then
		print('HAHAHHA BIG EXPLOSION *HAPPY CAT NOISE*')

		--[[local exp = Instance.new('Explosion')
		exp.BlastRadius = 1
		exp.BlastPressure = 1
		exp.Parent = Matar
		exp.Position = Matar.Position]]
	end
end)

RUN_EVENT.OnServerEvent:Connect(function()
	
	for i,v in pairs(BODY:GetChildren()) do
		
		if v:IsA('UnionOperation') or v:IsA('Part') or v:IsA('MeshPart') then
			if not v:FindFirstAncestor('Body') or not v:FindFirstAncestor('Wheels') then
				if not v:FindFirstChild('TouchInterest') then
					v.Touched:Connect(function(hit)

						if hit.Velocity.Magnitude >= 30 or v.Velocity.Magnitude >= 30 then

							if not hit:FindFirstAncestor('Body') or not hit:FindFirstAncestor('Wheels') then
								if hit.Name ~= 'Axle' then
									if not v:FindFirstChild('Crashed') then
										local crashsound = CRASHSOUND:Clone()
										crashsound.Parent = v
										--crashsound.SoundId = '8125594257'
										crashsound:Play()
										print('played')
										--wait(crashsound.TimeLength)
										--crashsound:Destroy()
										print("Destroyed")


										local Crashed = Instance.new('BoolValue')
										Crashed.Name = 'Crashed'
										Crashed.Parent = v
										Crashed.Value = true
										if v:FindFirstChild('TouchInterest') then
											--v:FindFirstChild('TouchInterest'):Destroy()
											v:BreakJoints()

											v.Anchored = false
											v.Parent = workspace
											--v.CFrame = v.CFrame * CFrame.new(0.1,0,0)
										else
											v:BreakJoints()

											v.Anchored = false
											v.Parent = workspace
											--v.CFrame = v.CFrame * CFrame.new(0.1,0,0)

										end



									end


								end


							end


						end
					end)
					
				else
					--v:FindFirstChild('TouchInterest'):Destroy()
					
				
				end
				
			end
			

			

		end

	end
end)

thank you for reading this! :smiley:

Mind posting a screenshot of the whole setup and explain a bit better what parts exactly you want to seperate on the impact.

He is just wanting explosion only effect for one part

The loop is nested with conditions which I don’t understand unless I see the setup

image

so these conditions make sure that what is getting hit is a part and not a script for example and it’s making sure that it’s not a part of the car for example if you move they were a chance for a part to detect another part of the car and crash the car

update: I might have found why i am still trying to analyze it

Hey! I found out why it was doing that! It was the part getting teleported in a workspace that was now considered a hittable, so it was making a chain!