How to make a part highlighted when near?

I want to make a part highlighted when near

StarterPlayer>StarterCharacterScripts>LocalScript

Use magnitude

local Character = script.Parent
local Torso = Character:WaitForChild("Torso")

local Distance = 10

local Part = workspace.Part

if (Part.Position - Torso.Position).magnitude <= Distance then
    Part.Highlight.Enabled = true
end
1 Like

Ok thanks!!!

Solution

local Character  = script.Parent
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local Distance = 100

local Part = workspace.Part1234


if (Part.Position - HumanoidRootPart.Position).magnitude <= Distance then
		Part.Highlight.Enabled = true
else
		Part.Highlight.Enabled = false
end
1 Like