i want to achieve a parkour vault system which works on various object sizes, i would like it to be the similar to games like PARKOUR or PARKOUR REBORN
the issue is, it only works some of the time and its very different and worse compared to vault scripts in games ive previously mentioned
local UIS = game:GetService("UserInputService")
local Character = script.Parent
local Root = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
-- Vault animation setup
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 to detect obstacles for vaulting
local VaultCastHead = workspace:Raycast(Character.Head.CFrame.Position + Vector3.new(0, -0.5, -0.5), Root.CFrame.LookVector * 5, Params)
local VaultCast = workspace:Raycast(Root.CFrame.Position + Vector3.new(0, -0.5, 0), Root.CFrame.LookVector * 3.5, Params)
if VaultCastHead then
return -- Don't vault if the head hits something
end
if not VaultCast then
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping) -- Normal jump if no obstacle detected
return
end
-- Vaulting logic
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false) -- Disable normal jumping
-- Get the obstacle instance
local obstacle = VaultCast.Instance
obstacle.CanCollide = false -- Temporarily disable collision
-- Check if the obstacle is a special vault enhancer
local isBoosted = obstacle:GetAttribute("VaultBoost") or false
-- Play the vault animation
VaultAnimTrack:Play()
-- Calculate landing position
local obstaclePosition = obstacle.Position
local obstacleHeight = obstacle.Size.Y / 2
local overshootDistance = isBoosted and 30 or 20 -- Adjust overshoot distances
local landingPosition = Vector3.new(
obstaclePosition.X,
obstaclePosition.Y + obstacleHeight + 1.5, -- Adjust for player height
obstaclePosition.Z
) + (Root.CFrame.LookVector * overshootDistance)
-- Apply vault motion with adjusted velocity
local vaultDirection = (landingPosition - Root.Position).unit
local baseSpeed = 70 -- Base forward speed during vault
local speedBoost = isBoosted and 40 or 10 -- Increased boost for special parts
local upwardMotion = isBoosted and 25 or 10 -- Higher vertical motion for boosted parts
Root.AssemblyLinearVelocity = vaultDirection * (baseSpeed + speedBoost) + Vector3.new(0, upwardMotion, 0)
-- Wait for the vault to complete
task.wait(0.4)
-- Stop the vault animation
VaultAnimTrack:Stop()
-- Restore obstacle collision
obstacle.CanCollide = true
-- Re-enable jumping
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
-- Reset velocity to avoid excess motion after the vault
Root.AssemblyLinearVelocity = Root.AssemblyLinearVelocity * 0.7 -- Smooth deceleration after vaulting
end)
this is my current script, it kinda works but its very janky and a bit broken, it also has a feature to boost on certain objects which i need for a stage in my game
any ideas on what i could do?