How to detect who’s 1st, 2nd, 3rd, etc in my racing game

Been trying to find tutorials of this everywhere, but couldnt. By the way, i mean during a race, because i already know you can detect them at the end of the race by seeing who touched it 1st. And this is also about with cars, not with people

1 Like

By somehow measuring the distance to the finish line.

Maybe use roblox studio’s built-in PathfindingService. What I am visualizing here is that you use the pathfinding service to pathfind to the finish line, and use :GetWaypoints() to get the list of waypoints. The length of that list can be used to measure the player’s distance to the finish line. You can then sort the players based on the length of the list of waypoints and have your players’s ranks.

I just googled “roblox checkpoint race car tutorial” and found a bunch of tutorials about it.
I’m pretty sure if you add more checkpoints on the track you’d have a better update of who’s first, etc.

This probably isn’t the correct solution but you could make a script in the finish line that basically says if a person crosses it puts them on a team called 1st place, if there’s already a players in the 1st place team, put the player is 2nd place and so on.

Check parttouched Events and Assign each part to a player and or a number and check the order in which it came in and boom

You might try using a race checkpoint system like in mario kart.

A short explanation is that the race has a bunch of invisible markers that track progress.

Increment the progress by 1 when a player passes through one of these invisible walls, then find the players who have the most progress. If there is more than 1 player with the highest amount of progress like 2 players with 15 checkpoints hit, then find whichever one is closest to the next checkpoint and you’ve got 1st place.

You can use this same system to sort every player in a row with table.sort.

I stole this image from a summoningsalt video, watch it if you want a much better explanation on how this progression tracker works.

3 Likes

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