Keep vehicle going after touching a (anchored) object

  1. What do you want to achieve?
    I have a destructible street light and a vehicle made by Roblox.
    When it’s destroyed, the car keeps going and the parts still collide.
  2. What is the issue?
    The street light itself works perfectly along with the effects but it stops the vehicle, which is not what I want.
  3. What solutions have you tried so far?
    Tried CollisionGroups, ApplyImpulse - no/bad results.
    Found three topics on devforum, but none of them helped me to fix the problem
    Tried using ChatGPT and Bard. They just show funny results.
    I also made the parts massless but I am not sure if it changed anything.
    I tried to do it using hitboxes - but I can’t get how it’s supposed to work, because when I tried adding a hitbox to a car and another to the street light, which will check if it’s touched like this:
-- The street light sensor script
script.Parent.Touched:Connect(function(touch)
	if touch.Name == "breaksensor" then
		script.Parent.Parent.Main.isBroken.Value = true
		script.Parent.Anchored = false
	end
end)

It does work, and the value changes, whereas the other script in the streetlight, which breaks it:

local Ball = script.Parent.Parent.Main
repeat
	script.Parent.Material = Enum.Material.Glass
	wait(1)
	script.Parent.Material = Enum.Material.Neon
	wait(1)
until script.Parent.Parent.isBroken.Value == true
script.Parent.Material = Enum.Material.Glass
script.Parent.Parent.Parent.BrokenParts.Broken.Break:Play()
for _, child in pairs(script.Parent.Parent.Parent.BrokenParts:GetChildren()) do
	child.Transparency = 0
end
for _, child in pairs(script.Parent.Parent:GetChildren()) do
	if child:IsA("BasePart") then
		child.Anchored = false
	end
end
script.Parent.Parent.Parent.BrokenParts.Broken.Debris.Enabled = true
wait(0.1)
script.Parent.Parent.Parent.BrokenParts.Broken.Debris.Enabled = false

just unanchors all parts.

Sometimes car stops:
carstops

Sometimes not:
cargoes

(used gifs because videos are always broken)

Maybe I should try using Raycasts or Welds, but can’t get of a idea how it would work.

1 Like

Have you tried setting the CustomPhysicalProperties of the pole to have a very low density? That way when it collides with the car, it shouldn’t significantly affect the car’s movement.

honestly you could just create a big non collide invisible part as the hitbox so it unanchors it before it gets hit

You could save the velocity and it’s direction and reapply it after the car has stopped.

Yes try this.

  • Keep track of the vehicle position and velocity every frame.
  • When the lamp detects if it has been hit by an assembly with enough mass and speed then check if it’s a vehicle.
  • If it’s a vehicle, destroy the lamp and then set the vehicle back to its position and velocity last frame.
  • You can play around with modifying the velocity and angular velocity of the vehicle in response to the collision.
1 Like

Hi, this is not possible because the physics is running from the server and they are slow. Use a local script, and velocity on parts.