Hello, I am using a script that makes an GUI visible when your cursor hovers over a part. ive been looking for tutorials on youtube and the devforum on how to make it based on distance, but i didnt really understand on how to do it in a script like mine.
Frontdoor is a Part in Workspace and the GUI is invisible in StarterGui, the script is inside the GUI.
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
while wait() do
if Mouse.Target ~=nil and Mouse.Target.Name == 'FrontDoor' then
script.Parent.Frame.Visible = true
else
script.Parent.Frame.Visible = false
end
end

2 comments
https://developer.roblox.com/en-us/api-reference/class/Player#distancefromcharacter-vector3-point- might be of assistance
Ive tried it but im not really understanding it.