Here’s the code I’m using for this…
local ray = game.Workspace:Raycast(char.HumanoidRootPart.Position + char.HumanoidRootPart.CFrame.LookVector * 0 ,-char.HumanoidRootPart.CFrame.UpVector * 11,rayparams)
local ray2 = game.Workspace:Raycast(char.HumanoidRootPart.Position + char.HumanoidRootPart.CFrame.LookVector * 2 ,-char.HumanoidRootPart.CFrame.UpVector * 11,rayparams)
local actualpushfactor = 0
local rot7 = 0
local rot6 = 0
local x, y, z = 0,0,0
local x2, y2, z2 = 0,0,0
local thelook = CFrame.Angles(0,1,0)
if ray and ray2 then
local raypos = ray.Position
first3.Position = ray2.Position
local boardpos = char.HumanoidRootPart.CFrame.p + Vector3.new(0,-1,0)
local check = (boardpos - raypos).Magnitude
local percentage = math.clamp(math.abs(check / pushfactor),0,1)
if firstray == false then
firstray = true
firstrayresult = ray.Normal
end
print(math.abs(percentage))
if check > wantedheight then
percentage = percentage
else
percentage = percentage
end
rot7 = ray2.Normal
rot6 = ray2.Position
x, y, z = rot7.X , rot7.Y ,rot7.Z
x2, y2, z2 = rot7.X , rot7.Y ,rot7.Z
print(x.." | "..y.." | "..z)
local reduction = pushfactor * percentage
thelook = CFrame.new(Vector3.new(char.HumanoidRootPart.Position),Vector3.new(char.HumanoidRootPart.Position) - Vector3.new(x,y,z))
actualpushfactor = pushfactor - reduction
thelook = getRotationBetween(char.HumanoidRootPart.CFrame.UpVector,ray2.Normal,Vector3.new(1,0,0))
print(thelook.LookVector.X .." | ".. thelook.LookVector.y .." | ".. thelook.LookVector.z)
else
rot7 = firstrayresult
x, y, z = rot7.X , rot7.Y ,rot7.Z
thelook = CFrame.new(Vector3.new(char.HumanoidRootPart.Position),Vector3.new(char.HumanoidRootPart.Position) - Vector3.new(x,y,z))
end
if rotation ~= 0 then
if ray then
rot.CFrame = CFrame.new(char.HumanoidRootPart.Position) * CFrame.Angles(thelook.UpVector.Z,0,thelook.UpVector.X ) * CFrame.Angles(math.rad(0),math.rad(-rotation + 180),math.rad(0))
else
rot.CFrame = CFrame.new(char.HumanoidRootPart.Position) * CFrame.Angles(thelook.LookVector.Z,0,thelook.LookVector.X) * CFrame.Angles(0,math.rad(-rotation + 180),0)
end
end
Sorry for all of the junk-text in it, I gotta clean it up after all of this…