Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a distance from part GUI?

Asked by 6 years ago

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

1 answer

Log in to vote
0
Answered by
theCJarmy7 1293 Moderation Voter
6 years ago

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)
0
Still confused on where I put those scripts, could you tell me? ShiforRBLX 5 — 6y
Ad

Answer this question