sup everyone so for some unknown reason my character like flickers around during a sliding animation. im using alignorientation with a code snippet below. if anybody knows what the heck is going on that would be very helpful thanks gurt
PosCheck = RunService.RenderStepped:Connect(function(dt)
local currentY = rootPart.Position.Y
local verticalChange = currentY - previousY
previousY = currentY
-- Determine slope behavior
if verticalChange > 0.01 then
-- Going uphill
CurrentMultiplier = math.clamp(CurrentMultiplier - Settings.SpeedChangeRate.Upward * dt, 0, Settings.MaxMultiplier)
elseif verticalChange < -0.01 then
-- Going downhill
CurrentMultiplier = math.clamp(CurrentMultiplier + Settings.SpeedChangeRate.Downward * dt, 0, Settings.MaxMultiplier)
else
-- Flat
CurrentMultiplier = math.clamp(CurrentMultiplier - Settings.SpeedChangeRate.Flat * dt, 0, Settings.MaxMultiplier)
end
-- Apply movement
local horizontalMove = Vector3.new(Humanoid.MoveDirection.X, 0, Humanoid.MoveDirection.Z)
-- Only slightly influence the slide direction
local influence = 0.1 -- small = slide mostly goes forward
if horizontalMove.Magnitude > 0 then
local targetDir = (slideDir + horizontalMove.Unit * influence).Unit
slideDir = slideDir:Lerp(targetDir, 0.1).Unit
end
-- Then apply horizontal velocity
local horizontalVel = slideDir * (Settings.BaseSpeed * CurrentMultiplier)
-- Smooth velocity lerp for less jerky movement
local currentVel = Vector3.new(rootPart.AssemblyLinearVelocity.X, 0, rootPart.AssemblyLinearVelocity.Z)
horizontalVel = currentVel:Lerp(horizontalVel, 0.2) -- smooth factor 0.2
rootPart.AssemblyLinearVelocity = horizontalVel + Vector3.new(0, rootPart.AssemblyLinearVelocity.Y, 0)
local rayDir = rootPart.CFrame.UpVector * -10
local groundRay = workspace:Raycast(rootPart.Position,rayDir,rayParams)
if groundRay then
local up = groundRay.Normal
-- Forward direction is the original slideDir (horizontal)
local forward = Vector3.new(slideDir.X, 0, slideDir.Z).Unit
-- Right vector perpendicular to up and forward
local right = forward:Cross(up).Unit
-- Compute lean: rotate a bit toward horizontalMove
local leanAmount = 0.2 -- 0 = no lean, 1 = full sideways
if horizontalMove.Magnitude > 0 then
local leanDir = Vector3.new(horizontalMove.X, 0, horizontalMove.Z).Unit
forward = (forward:Lerp(leanDir, leanAmount)).Unit
right = forward:Cross(up).Unit
end
-- Final orientation
local backForward = right:Cross(up).Unit
-- Compute target orientation as before
local targetCFrame = CFrame.fromMatrix(rootPart.Position, right, up, backForward)
-- Smoothly interpolate from previous orientation
alignOrientation.CFrame = alignOrientation.CFrame:Lerp(targetCFrame, 0.2) -- tweak 0.1-0.3
end
alignOrientation = Instance.new(“AlignOrientation”)
alignOrientation.MaxTorque = 40000
alignOrientation.Responsiveness = 10000
alignOrientation.Attachment0 = rootPart:FindFirstChildOfClass(“Attachment”)
alignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
alignOrientation.Parent = Character
PosCheck = RunService.RenderStepped:Connect(function(dt)
local currentY = rootPart.Position.Y
local verticalChange = currentY - previousY
previousY = currentY
-- Determine slope behavior
if verticalChange > 0.01 then
-- Going uphill
CurrentMultiplier = math.clamp(CurrentMultiplier - Settings.SpeedChangeRate.Upward * dt, 0, Settings.MaxMultiplier)
elseif verticalChange < -0.01 then
-- Going downhill
CurrentMultiplier = math.clamp(CurrentMultiplier + Settings.SpeedChangeRate.Downward * dt, 0, Settings.MaxMultiplier)
else
-- Flat
CurrentMultiplier = math.clamp(CurrentMultiplier - Settings.SpeedChangeRate.Flat * dt, 0, Settings.MaxMultiplier)
end
-- Apply movement
local horizontalMove = Vector3.new(Humanoid.MoveDirection.X, 0, Humanoid.MoveDirection.Z)
-- Only slightly influence the slide direction
local influence = 0.1 -- small = slide mostly goes forward
if horizontalMove.Magnitude > 0 then
local targetDir = (slideDir + horizontalMove.Unit * influence).Unit
slideDir = slideDir:Lerp(targetDir, 0.1).Unit
end
-- Then apply horizontal velocity
local horizontalVel = slideDir * (Settings.BaseSpeed * CurrentMultiplier)
-- Smooth velocity lerp for less jerky movement
local currentVel = Vector3.new(rootPart.AssemblyLinearVelocity.X, 0, rootPart.AssemblyLinearVelocity.Z)
horizontalVel = currentVel:Lerp(horizontalVel, 0.2) -- smooth factor 0.2
rootPart.AssemblyLinearVelocity = horizontalVel + Vector3.new(0, rootPart.AssemblyLinearVelocity.Y, 0)
local rayDir = rootPart.CFrame.UpVector * -10
local groundRay = workspace:Raycast(rootPart.Position,rayDir,rayParams)
if groundRay then
local up = groundRay.Normal
-- Forward direction is the original slideDir (horizontal)
local forward = Vector3.new(slideDir.X, 0, slideDir.Z).Unit
-- Right vector perpendicular to up and forward
local right = forward:Cross(up).Unit
-- Compute lean: rotate a bit toward horizontalMove
local leanAmount = 0.2 -- 0 = no lean, 1 = full sideways
if horizontalMove.Magnitude > 0 then
local leanDir = Vector3.new(horizontalMove.X, 0, horizontalMove.Z).Unit
forward = (forward:Lerp(leanDir, leanAmount)).Unit
right = forward:Cross(up).Unit
end
-- Final orientation
local backForward = right:Cross(up).Unit
-- Compute target orientation as before
local targetCFrame = CFrame.fromMatrix(rootPart.Position, right, up, backForward)
-- Smoothly interpolate from previous orientation
alignOrientation.CFrame = alignOrientation.CFrame:Lerp(targetCFrame, 0.2) -- tweak 0.1-0.3
end
js put it into a lua code chunk so its easier to read - ill give it some thought
also the chat gpt is so obvious nothing wrong in using it tho
Setting a parts AssemblyLinearVelocity directly is probably interfering with your AlignOrientation. Use something like a VectorForce or a LinearVelocity instead. Also at the end, you don’t need to lerp the AlignOrientation because that’s already handled on the Responsiveness property (sortof but you get literally the same effect). Also, did you disable AutoRotate on the humanoid? And is PlatformStand enabled?
totally my bad guys it was a freaking problem with my fp camera script stupid me shouldn’t trust nonna the shart on the toolbox but thanks for offering y’all’s help