Code works in studio but not in-game

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

My intuition isn’t telling me to check any particular thing based on what I saw in the video. I don’t notice anything in your code either. My suggestion is to try printing stuff in various parts of your code like print’start’ and print’end’.

I have found the issue. In studio, upAlpha is calculated perfectly fine. In-game, the upAlpha is calculated as nan for some reason. I have absolutely zero clue why this happens.

maybe it’s something to do with calculating “length”

it was the animation, it turns out it was a sanitized id

1 Like