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
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).
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