Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to find who's in 1st, 2nd, 3rd, etc?

Asked by 7 years ago

I'm making a racing game and one of the only challenges remaining is how to figure out who is in first, second, third, etc. I want it to be able to update as the race is in progress.

0
Where's your code? We can't help without your attempt(s). Sorry! starlebVerse 685 — 7y
0
The problem is I don't have any attempts. I have no idea where to begin! I'm looking for a little guidance. fireflame09225 11 — 7y

1 answer

Log in to vote
3
Answered by 7 years ago
Edited 7 years ago

Know what? I thought about that last night. IDK why, I don't even need it :D There are a few ways to do it, the easiest one is putting checkpoints. Visible or not, checkpoints must be at each corner to make script get it straighter. If person A passed checkpoint 6 and person B passed checkpoint 7, person B is closer to finish and should be 1st. If both of them are in same checkpoint and if person A is closer than person B to next checkpoint, person A should be 1st. (You can use Vector3.magnitude to calculate length between two points. If you need an example, send a comment.)

Second option is Pathfinding service of Roblox, easy for an intermediate scripter, but can create mistakes easily. If ways are clear enough for roblox players too, you can use Pathfinding but have to put at least one checkpoint to make sure pathfinding does not show back. Also Pathfinding service can only calculate shorter than 500 studs, and its pretty short for a car race. For short, I do not suggest it.

Note for viewers: I do not know if there are another ways to do this, so please do not rage on me, just put your thoughts on comments.

0
I like the checkpoints idea. It seems kind of difficult to pull off, so if you have an example I'd love to see it! fireflame09225 11 — 7y
0
Also, how can I easily manage the positions/checkpoints of all 8 players? Will I have to loop through each one and individually check their stats? fireflame09225 11 — 7y
1
I researched in my Roblox Studio library and couldn't find an example, sorry. And yes, you have to check all of stats. superalp1111 662 — 7y
Ad

Answer this question