How to calculate the distance of some two parts?

Hello!
I don’t know how to calculate the distance from some part to other part in studs.
Any reply helps Thanks!

please look up your questions before posting

local runService = game:GetService(“RunService”)

MagnitudeRange = (partA.Position - partB.Position).Magnitude

runService.HeartBeat:Connect(functiion()
print(MagnitudeRange)
end)

might have been wrong

first I need to do a lot of edits to the script but anyway, I fixed it but it lags EXTREMELY.
And I want to make it refresh every second…

It lags? it’s supposed to be on client

my bad i did some accidents and stuff. What are you trying to do? so i can make a proper one

What exactly do you need it for? Chance is there’s a more efficient / cleaner way to achieve what you want.

the only reason it lags is because you’re printing every frame, remove the print and it shouldn’t lag.

I’m making a game where you control a car and you need to make it to the end i need it for the indicator GUI that show how many studs you have left.

locla Distance = (part1.Position-endpart.Position).Magnitude