if OnRail then
local HRPlookVector = HRP.CFrame.lookVector
local RailForward = Rail.CFrame.lookVector -- rail's lookvector
local RailBackward = Rail.CFrame.lookVector * -1 -- rail's backvector
if (HRPlookVector - RailForward).Magnitude < (HRPlookVector - RailBackward).Magnitude then
print("Right")
GrindDirection = "Right"
else
print("Left")
GrindDirection = "Left"
end
else
GrindDirection = nil
end
I wasn’t quite sure how to use MoveDirection in this context, but I did figure this out eventually. I checked the magnitude between the HumanoidRootPart’s lookVector and the rail’s lookVector
If Humanoid.MoveDirection can provide a more efficient or accurate way to detect the direction the player moves across the rail, I’m open to change