I made a script and two textlabels to detect how far you are from the bluepart and a green part. I’m just wondering if this is the best way to find the distance between blue part and green part. Code:
local player = game.Players.LocalPlayer
local bluePart = game.Workspace.BluePart
local greenPart = game.Workspace.GreenPart
local distanceGreen = player.PlayerGui:WaitForChild("Main").DistanceGreen
local distanceBlue = player.PlayerGui:WaitForChild("Main").DistanceBlue
local findChar = game.Workspace:FindFirstChild(player.Name) -- Finding player's character in workspace
local humanoidRoot = findChar.HumanoidRootPart -- Grabing the player's HumanoidRootPart
while true do
local playerDistBlue = (humanoidRoot.Position - bluePart.Position).magnitude --[[ Finding the distance between
HumanoidRootPart and bluePart --]]
wait()
distanceBlue.Text = "You are " .. math.floor(playerDistBlue) .. " studs away from the BluePart!"
local playerDistGreen = (humanoidRoot.Position - greenPart.Position).magnitude --[[ Finding the distance between
HumanoidRootPart and bluePart --]]
distanceGreen.Text = "You are " .. math.floor(playerDistGreen) .. " studs away from the GreenPart!"
end
Any response it appreciated!