Hiiiii! I’m doing a vaulting system for my game and thanks to the help of some people I’ve gotten really far with it! The only problem is that for some weird reason the vaulting works but it slowly stops working with each time I press the button up until it just completely stops from getting the player to the other side. From what I know my script is working perfectly and this problem happens every single time; I suspect it isn’t related to scripting because that pattern is like connected to other vaulting walls too and when it stops working in one it stops working in all of them! It’s super confusing if someone knows what going on I would appreciate the help!
#Weird vaulting error pattern
1 messages · Page 1 of 1 (latest)
The code I’m using is this:
local ProximityPrompt = script.Parent
local wall = script.Parent.Parent
local AnimationId = "rbxassetid://123"
ProximityPrompt.Triggered:Connect(function(player)
if not player or not player.Character then return end
-- Disable prompt temporarily
ProximityPrompt.Enabled = false
task.delay(3, function()
ProximityPrompt.Enabled = true
end)
local character = player.Character
local humanoid = character:FindFirstChildOfClass("Humanoid")
local hrp = character:FindFirstChild("HumanoidRootPart")
local torso = character:FindFirstChild("UpperTorso") or character:FindFirstChild("Torso")
if not humanoid or not hrp or not torso then return end
-- Freeze character movement
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
-- Calculate vault direction freshly
local wallLook = wall.CFrame.LookVector
local directionToPlayer = (hrp.Position - wall.Position).Unit
local dot = wallLook:Dot(directionToPlayer)
local directionMultiplier = dot > 0 and 1 or -1
local vaultDirection = wallLook * directionMultiplier
-- Position the player correctly before the vault
local distanceFromWall = 2
local vaultPosition = wall.Position + vaultDirection * distanceFromWall
hrp.CFrame = CFrame.new(vaultPosition, wall.Position)
task.wait(0.1)
-- Load the animation
local animation = Instance.new("Animation")
animation.AnimationId = AnimationId
local animator = humanoid:FindFirstChildOfClass("Animator")
local track = animator and animator:LoadAnimation(animation) or humanoid:LoadAnimation(animation)
if not track then
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
return
end
-- Play and connect vault-over logic
track:Play()
local connection
connection = track:GetMarkerReachedSignal("VaultOver"):Connect(function()
if connection then
connection:Disconnect()
end
-- Move to other side
if torso then
hrp.Position = torso.Position
else
hrp.CFrame = hrp.CFrame + vaultDirection * 4
end
-- Cleanup track
track:Stop()
end)
-- Restore movement
task.delay(3, function()
if humanoid then
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
end
end)
end)
And literally even if u don’t know please tell me either way so I know it’s actually something uncommon and weird!
Using hrp.CFrame = hrp.CFrame + vaultDirection * 4 can become less accurate over time because it keeps adding small position shifts. Also, setting hrp.Position directly can cause the player to keep their velocity, which might mess up collision detection
OMG YESSSS I CHANGED THAT AND IT WORKS NOWWWWWWWW! TYSM I RLLY APPRECIATE SO MUCH!