I’ve been working on a bonking system for if a player rolls/dives into a wall, and it’s supposed to bounce the player slightly back. But, sometimes the player gets stuck in the wall, which can sometimes lead to the player being launched. If you are trying to help, please provide script examples.
Bounce Script Snippet:
--wallPos is the raycast position
local function Bonk(wallPos)
if Diving or Rolling then
Animations.Dive:Stop()
Animations.Roll:Stop()
Animations.Jump:Stop()
Animations.Run:Stop()
Animations.Idle:Stop()
Animations.Bonk:Play()
if Character.HumanoidRootPart:FindFirstChild("BodyVelocity") then
Character.HumanoidRootPart.BodyVelocity:Destroy()
end
Character.HumanoidRootPart.CFrame = CFrame.lookAt(Character.HumanoidRootPart.Position, wallPos)
local bodyVel = Instance.new("BodyVelocity")
bodyVel.MaxForce = Vector3.new(math.huge, 0, 0)
bodyVel.P = math.huge
bodyVel.Parent = Character.HumanoidRootPart
bodyVel.Velocity = (Character.HumanoidRootPart.CFrame.LookVector * -16) + Vector3.new(0, -8, 0)
task.wait(1.5)
bodyVel:Destroy()
Bonked = false
end
end