How to fix my Vaulting?

I’m working on a vaulting mechanic, but occasionally when the player tries to vault this happens.

As you can see, the player falls flat on it’s face.
Here’s my code:

local function Vault()
	playAnim:Play()
	
	print("Vaulting")
	local Vel = Instance.new("BodyVelocity")
	Vel.Parent = HumanoidRootPart
	Vel.Velocity = Vector3.new(0,0,0)
	Vel.MaxForce = Vector3.new(1,1,1) * math.huge
	Vel.Velocity = HumanoidRootPart.CFrame.LookVector * 30 + Vector3.new(0,10,0) 
	wait(0.15)
	Vel:Destroy()
	
	print("Vault Complete")
end

Thank you!

it hits the part while Vaulting, it can cause that, try playing with max force or just make it not collide with a part for a moment. there are many ways to make it not trip like that

3 Likes

It’s colliding with the part which makes it fling your player what you can do it make a boolean and when the player is currently vaulting, make the part cancollide = false, when the bodyvelocity is destroyed meaning the vault is completed, make the part collision to true, assuming this is a local script it wouldn’t mess with other players being able to phase through the part.




local function Vault()
	playAnim:Play()
    local Part = script.parent -- define your part here


	
	print("Vaulting")
    Part.CanCollide = false
	local Vel = Instance.new("BodyVelocity")
	Vel.Parent = HumanoidRootPart
	Vel.Velocity = Vector3.new(0,0,0)
	Vel.MaxForce = Vector3.new(1,1,1) * math.huge
	Vel.Velocity = HumanoidRootPart.CFrame.LookVector * 30 + Vector3.new(0,10,0) 
	wait(0.15)
	Vel:Destroy()
	
   part.CanCollide = true
	print("Vault Complete")
end
1 Like

You can disable ragdolling.

humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)

BodyVelocity is also deprecated. Use AlignPosition instead: AlignPosition | Documentation - Roblox Creator Hub

3 Likes

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