I want to have a ScreenGUI that gets the distance from a Part in Workspace and updates the distance if the player walks away from it or closer to it
COMMUNITY QUESTION
How to make a distance from part GUI?
1 answer
Just like the comment says, you would use magnitude!
local p1 = game.Workspace.Part1.Position
local p2 = game.Workspace.Part1.Position
local distanceBetweenThem = (p1-p2).magnitude
As for having a gui update when the player moves, I would recommend using the .Changed property which can be found in all Instances.
local part = playerCharacter:WaitForChild("HumanoidRootPart")
part.Changed:connect(function()
--then simply apply the distance code I gave you to this
end)
1 comment
0
Still confused on where I put those scripts, could you tell me?
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
http://wiki.roblox.com/index.php?title=Magnitude