i have improved on a parkour script that was made (not originally by me) so when i press space/jump i vault over it, however its extremely janky and not smooth at all,
local UIS = game:GetService("UserInputService")
local Character = script.Parent
local Root = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
-- Add a vault animation
local VaultAnimation = Instance.new("Animation")
VaultAnimation.AnimationId = "rbxassetid://128897073877701" -- Replace with your animation ID
local VaultAnimTrack = Humanoid:LoadAnimation(VaultAnimation)
local Params = RaycastParams.new()
Params.RespectCanCollide = true
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {Character, workspace.CurrentCamera}
UIS.JumpRequest:Connect(function()
if Humanoid.FloorMaterial == Enum.Material.Air then
return
end
-- Perform raycasts for the vault detection
local VaultCastHead = workspace:Raycast(Character.Head.CFrame.Position + Vector3.new(0, -.5, -.5), Root.CFrame.LookVector * 5, Params)
local VaultCast = workspace:Raycast(Root.CFrame.Position + Vector3.new(0, -.5, 0), Root.CFrame.LookVector * 3.5, Params)
if VaultCastHead then
return
end
if not VaultCast then
-- Normal jump
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
return
end
-- Vaulting logic
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false) -- Disable normal jumping
-- Set the obstacle to non-collidable
VaultCast.Instance.CanCollide = false
-- Play vault animation
VaultAnimTrack:Play()
-- Physics-based vaulting motion
Root.AssemblyLinearVelocity = Root.CFrame.LookVector * 50 + Vector3.new(0, 5, 0) -- Adjust speed for smoother vaulting
-- Wait for the duration of the vault
task.wait(0.8) -- Adjust the wait time to match the animation length
-- Restore obstacle collision
VaultCast.Instance.CanCollide = true
-- Re-enable jumping
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end)
When you start your vaulting change it to 0 and when finish change it back to old as it was:
local UIS = game:GetService("UserInputService")
local Character = script.Parent
local Root = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
local oldgravity = workspace.Gravity
-- Add a vault animation
local VaultAnimation = Instance.new("Animation")
VaultAnimation.AnimationId = "rbxassetid://128897073877701" -- Replace with your animation ID
local VaultAnimTrack = Humanoid:LoadAnimation(VaultAnimation)
local Params = RaycastParams.new()
Params.RespectCanCollide = true
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {Character, workspace.CurrentCamera}
UIS.JumpRequest:Connect(function()
if Humanoid.FloorMaterial == Enum.Material.Air then
return
end
-- Perform raycasts for the vault detection
local VaultCastHead = workspace:Raycast(Character.Head.CFrame.Position + Vector3.new(0, -.5, -.5), Root.CFrame.LookVector * 5, Params)
local VaultCast = workspace:Raycast(Root.CFrame.Position + Vector3.new(0, -.5, 0), Root.CFrame.LookVector * 3.5, Params)
if VaultCastHead then
return
end
if not VaultCast then
-- Normal jump
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
return
end
-- Vaulting logic
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false) -- Disable normal jumping
-- Set the obstacle to non-collidable
VaultCast.Instance.CanCollide = false
workspace.Gravity = 0
-- Play vault animation
VaultAnimTrack:Play()
-- Physics-based vaulting motion
Root.AssemblyLinearVelocity = Root.CFrame.LookVector * 50 + Vector3.new(0, 5, 0) -- Adjust speed for smoother vaulting
-- Wait for the duration of the vault
task.wait(0.8) -- Adjust the wait time to match the animation length
-- Restore obstacle collision
VaultCast.Instance.CanCollide = true
-- Re-enable jumping
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
workspace.Gravity = oldgravity
end)