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

how do you get player farther away than 100 studs?

How do you get all the players that are farther away than 100 studs than the local player

1 answer

✓ Accepted answer

Magnitude


Using magnitude can allow you to get the distance from any two parts in studs. You can use magnitude in your case like this: Loop through all valid players like so:

For indexPlayer, Player in pairs (game.Players:GetPlayers()) do
       --do stuff
end

Then within the loop you can use magnitude like so:

if (Character.HumanoidRootPart.Position - Player.Character:WaitForChild( "HumanoidRootPart").Position).Magnitude >100 then
   --do stuff
end

Sorry about indenting, I did this directly on scripting helpers.

1 comment

0

Thank you so much

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