I am working on a movement system for a game and I have found that the vaulting works perfectly in studio for myself, but it doesn’t work in-game or for others properly.
In Studio:
In-Game:
I have absolutely zero clue why this happens because I haven’t dealt with it before.
Code:
local startPos = CFrame.new(char.PrimaryPart.Position)*CFrame.Angles(x,y,z)
local startY = startPos.Y
local alpha = 0
local lerping
lerping = game["Run Service"].RenderStepped:Connect(function(delta)
alpha += delta/length
local upAlpha = math.sin((alpha * math.pi * 2)/2)
local up = CFrame.identity:Lerp(config:GetAttribute("VaultOffset"),upAlpha)
local x2,y2,z2 = up:ToOrientation()
up = CFrame.new(up.X,math.clamp(up.Y,0.1,math.huge),up.Z)*CFrame.Angles(x2,y2,z2)
local newCF = (startPos:Lerp(pos,alpha))*up*CFrame.Angles(x,y,z)
local x3,y3,z3 = newCF:ToOrientation()
newCF = CFrame.new(newCF.X,math.clamp(newCF.Y,startY,math.huge),newCF.Z)*CFrame.Angles(x3,y3,z3)
char.PrimaryPart.CFrame = newCF
if alpha >= 1 then
lerping:Disconnect()
end
end)
task.wait(length)
currentMove = GetMovementInput(InputType)*speed
left:Destroy()
leftControl:Destroy()
right:Destroy()
rightControl:Destroy()
tracks.Vault:Stop()
char.PrimaryPart.Anchored = false
vaulting = false