Adjusting player angle to the floor's angle

Currently I am trying to make movement up roblox terrain look smoother, the issue is that the terrain’s angle changes a lot and very minimally, how could I make it look less jumpy? This is what I have so far:

local char = script.Parent
local rootPart = char:WaitForChild("HumanoidRootPart")
local xzGyro ="BodyGyro")
local yGyro ="BodyGyro")
yGyro.MaxTorque =,3e5,0)
yGyro.P = 5e5
xzGyro.MaxTorque =,0,3e5)
xzGyro.P = 5e5
xzGyro.Parent = rootPart

while wait() do
	local params =
	params.FilterDescendantsInstances = {char}
	params.FilterType = Enum.RaycastFilterType.Exclude
	local result = workspace:Raycast(rootPart.Position,,-10,0), params)

	yGyro.CFrame =, rootPart.Position + char.Humanoid.MoveDirection*10)

	if (result) then
		local currentRightVector = rootPart.CFrame.RightVector
		local upVector = result.Normal
		local newFacialVector = currentRightVector:Cross(upVector)
		xzGyro.CFrame = CFrame.fromMatrix(rootPart.Position, currentRightVector, upVector, newFacialVector)


Help appreciated, thanks!

you can adjust the dampening and power values of the body gyro to make it smoother. Alternatively, you can lerp the newFacialVector with the previous newFacialVector.


Works amazing, don’t know how I missed it… Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.