Magnitude Issues

I’m trying to work out if 2 players are close to each other. This is not working reliably and I am not sure of my error.


(The 2 players physical distance)

It returns a high number.
Any help is appreciated. I am not used to working with 3D so please bear with me.

Could you show the code, so we can help you? Right now, I don’t even know what I’m trying to do. The error could be because you’re indexing the wrong player, object, or because of something else entirely.

1 Like

It was a console command (f9 menu) so the screenshot is the whole entire code

It’s a one line command from the F9 menu, That’s all the issue is. I show where both players are and also show the result of the magnitude code

for i, v in ipairs(game.Players:GetChildren()) do
    print(v)
end

check if there is duplicate objects with the same name.
(if so then the error is that as said above from mejackdaawesome “you’re indexing the wrong player, object”)

Oh, whoops, didn’t see that. Are there multiple objects with the same name, perhaps?

Wait, he used player.Character, so unless you play with a second rig, there should be no problem.

It’s Player.Character, The player can only have one character and that is the one displayed on screen. I have redone this test with the specific parts indexed from workspace, and the result is the same. There are no other instances named either “ScotWARE” or “Rytimiscuristin” on the map

There could be another object under players with the same name

edit: nvm i see now

The Players game service contains only Player objects for presently connected clients to a Roblox game server.

I know this is random but have you tried doing this in a script instead of the command bar? It could be that the command bar is just acting weird when in game.

The code seems like it should work.

Try with 2 random objects first, that way we know if the problem is with magnitude or just this one situation. Also, do you know if this works in the code itself or not? Sometimes there can be disparencies between local and server if you use localscripts.

That line of code is originally from an if statement that was failing to pass.

It’s only happening with the players. I must also note that the magnitude sometimes is under 10 depending on where the players are on the map.

do you have any scripts to control the player’s CFrame running?

also for another test print both player’s head positions (just to see if there is something wrong with positioning)

I dont know what you mean by that. You mean the condition of the if statement wasnt met? Or did it error?

Why not just put that line of code in a every second loop in a blank script to see if it’s just the command bar thats the problem

That sounds like you are trying to find the magnitude of something other than the players, since different areas of the map are closer to it, but I may be wrong.

Try moving a Part to the positions you are passing in to find the positions that you are using for the magnitude. It seems unlikely that roblox’s own services would have an error.

You should use Character.PrimaryPart rather than head.

1 Like

The only thing that could potentially do that is animation players.
Here is a test showing both players head positions.


As you can see, they are now close by, unlike in the original post. This makes it seem fixed.
As we move away from that area, stuff changes.

I was thinking of using humanoidrootpart, as that would probably be more accurate. I’m just worried that this issue is an underlying issue with the game and I would simply be covering it.