How can I find out how many studs away a player is from a part?

Hello! I came here to figure out how I can calculate studs. I am fairly new to this type of stuff, and this will be beneficial for up to now. If possible, I would want milistuds so I can easily create a ranking system.

Please guide me into creating a studs from a certain part!

Thanks, Bill

1 Like

You could either use Player:DistanceFromCharacter() or .Magnitude

2 Likes

User a local script

local part = --your part here
local distanceInStuds = "Character not yet loaded"
if game.Players.LocalPlayer.Character then
    distanceInStuds = (game.Players.LocalPlayer.Character.HumanoidRootPart.Position - part.Position).Magnitude
end
print(distanceInStuds)
1 Like

Ok. What would be the most efficient way of getting the new value every time the player moves?

(They are driving btw)

1 Like

You could have a loop that checks
(humanoidrootpart.position-part.position).Magnitude

1 Like

Put this in a local script:

local part = --your part here
local distanceInStuds = "Character not yet loaded"
local waitTime = 0.5 -- set this to the delay time between each time you check the distance
while task.wait(waitTime) do
    if game.Players.LocalPlayer.Character then
        distanceInStuds = (game.Players.LocalPlayer.Character.HumanoidRootPart.Position - part.Position).Magnitude
    end
    print(distanceInStuds)
end
1 Like

Hi! I am trying to do this on the server lol. Also, this script would be incompatible with my game.

1 Like

Why do you want to do it from the server? Why do you need it in the game?

1 Like

To figure out a ranking system. I need this info to create a ranking system. Plus, I already went with @Platoon73 and forgot to mark as solution. Mb lol.

1 Like