How can I check if a player is on a slope?

Im trying to make a roll mechanic so that a player rolling down a slope can get a speed boost as they go to down if their rolling.

But Im not sure how Im supposed to check if their on a slope.

You can probably fire a ray down from the players location and check the raycast result’s normal vector and use that to determine if it’s angled or not.

An explanation of Normal Vectors can be found here:

and the api for RaycastResult are here:


Yep like @Motofied said.

To add on to get the direction pointing down the slope you can use cross product of the normal vector with the downvector.


How would I know if the player is going higher or lower on a slope though?

Check the difference in the Y axis positional value of their root part?

1 Like

Love that this reply is still being linked to 3 years after I posted it!

@StarJ3M as @Forummer said, you could track the Y-position of the HumanoidRootPart. You can also look at the root part’s velocity (BasePart.Velocity)


Would it be smarter to use a raycast, or track the Y position of the Cframe?

and also, how would I even track the Y position and check if its value went up or down?

So to check if its angled, could I use some sort of function to check if its a decimal, because my Wedge’s always end up outputing a decimal value.

And after that, how would I check if the players torso.Position.Y is increasing or decreasing?

Developers aren’t on the DevForum to design an algorithm for - try to come up with a solution before asking for one.

Your first question depends on what you’re trying to achieve. The way to get the answer is to understand how you’d implement each solution, and then decide for yourself which one makes the most sense. When solving a problem in computer science you want to be reducing memory usage, algorithm complexity, and execution time, whilst increasing functionality, code readability, and codebase health.

You can’t have everything though, and you’ll need to make trade-offs. The most common trade-offs are improving readability at the expense of increased execution time, and improving execution time at the expense of increased memory usage. These also exist in the inverse.

For your second question: you’d track the change of the y-position by saving it at one point in time, and then checking it at another point in time, and then comparing the difference. If the player was at y-position 50.4, and is now at y-position 43.7, then they’ve gone down 6.7 studs, and are descending.
How you go about the details of implementing this is specific to your project, and you’ll need to decide that yourself. I would suggest looking at the RunService