Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What's the best tactic to check if something is in a certain position?

So, this is something that I've wanted to learn for a long time now and I don't expect the answer to be short. I am making a running simulator where I have "Speed orbs" that increases the player's speed when he or she touches it. I want the orbs to appear randomly on the map but in some cases, the orbs may spawn at the same location and I don't mean that as in the exact same position but close enough to touch each other. So my question is, what tactic should I use to check if a part is already in a certain position so that two orbs don't end up too close to each other and so that I can use it in other cases?

Edit: If it wasn't clear enough in the original post, I don't mean how do I check if something is in an exact position, that's easy to do with: if(Object).Position == (position) then. I am wondering how I can check if the new orb I will spawn in any way will interfere with an old orb

Edit2: I have been scripting for over a year now and can thus take on complicated ways to do this

2 comments

0

don't post primarily opinion-based questions...

0

if statement

1 answer

✓ Accepted answer

Since this is a site dedicated to helping and not creating codes, I can't really give you a code. But I can say that you can use magnitude to check if it is too close.

3 comments

0

Well, I'm sorry if this wasn't clear enough in the main question, but I have no interest in just receiving a code as I would not learn anything from it and would not be able to apply it in anything else. I am just asking about how I can go about this problem and a little bit of how to think

0

Nvm, saying that I can use magnitude to do this is more than enough, thank you so much!

0

Wow, that was much easier than I thought it was gonna be. I imagined tens of lines of complicated code but all that was needed was one line and I got the distance between two parts. Honestly it is so simple that I feel kinda dumb for not figuring it out by myself, thanks again!

This discussion is preserved as it was. New answers, comments, and votes are closed.