How to make a door breakdown effect

Im making it so a door breaks down when it’s punched by players. My goal is to make the door fly backwards a bit when it’s broken. So far I have tried using LinearVelocity and it’s got me nowhere and Im stuck on what to do.

Also another question: How would I make the door break when an explosion happens.

My script

function door.Breakdown(door, humanoidRootPart) -- this needs work
	local Direction = humanoidRootPart.CFrame.LookVector
	
	local ForceAttatchment = Instance.new("Attachment")
	ForceAttatchment.Parent = door.DoorParts.Base
	ForceAttatchment.CFrame = door.DoorParts.Base.CFrame
	
	local LinearVelocity = Instance.new("LinearVelocity")
	LinearVelocity.Parent = door
	LinearVelocity.MaxForce = 50
	LinearVelocity.LineDirection = Direction
	LinearVelocity.VectorVelocity = Direction * 2
	LinearVelocity.Attachment0 = ForceAttatchment
	
	door.DoorParts.Base.DoorBreak:Play()
	door.Hinge:Destroy()
	door:FindFirstChild("OpenPart"):Destroy()
	door:FindFirstChild("LockPart"):Destroy()
	
	task.delay(0.2, function()
		LinearVelocity:Destroy()
		ForceAttatchment:Destroy()
	end)
end
1 Like

You could try using they objects velocity. (door.Base.Velocity = humanoidRootPart.CFrame.LookVector * your explosion power, Ex. 100) And as for explosions, first use workspace:GetPartsBoundInRadius() to get the parts in the explosions radius. Second check if any of the parts are a door, There are multiple ways to check. One way is tags. Then just get the direction by doing CFrame.new(door.Base.Position,explosincentervector3).LookVector and then times it by your explosion power. In this case 100).

This didn’t work the door just fell down on the ground and tipped over when i touched it, absolutely no force is visible on it.

Make sure you apply the force after its unanchored/unhinged and make sure that the power is high enough

It’s unanchored, since it’s a door the door parts are unanchored and welded to the hinge (the hinge is anchored) so I just destroy the hinge before applying the force, I even tried looping through the door parts and applying the force but the same thing happened. I literally set the force to 150

Hmm there must be something wrong with the script Ill make a demo to show that it works

1 Like

your max force is too small, and your velocity might be too

a good alternative would be bodyvelocity, looking something like this

local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge, 0, math.huge)
bv.Velocity = Direction * 10
bv.Parent = door
game.Debris:AddItem(bv, .2)

BodyVelocity is deprecated but I tried it and it sort of worked ig.

deprecated means its no longer supported, but it works, but if you really want something not deprecated, use AssemblyLinearVelocity

door.AssemblyLinearVelocity = Direction * 10
1 Like
External Media

edit-i uploaded it to streamable im not sure why it wants me to download it

heres the script i used in the video:

script.Parent.MouseClick:Connect(function(plr)
print(“punch”)
script.Parent.Parent.Anchored = false
wait(0.1)
script.Parent.Parent.Velocity = plr.Character.HumanoidRootPart.CFrame.LookVector * 100
end)

Note: also it would be better if you used the cameras cframe lookvector since you could hit the door up

1 Like

Velocity is deprecated for AssemblyLinearVelocity, which would function the same

2 Likes

Hmm I was unaware of AssemblyLinearVelocity lol. In that case just use AssemblyLinearVelocity in place of Velocity

1 Like

yep, that should be the solution and your script should be marked as such

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.