I solved this issue after many hours of experimenting with magnitude; thanks to any who responded.
To make a gui visible from a certain distance, I have this working script:
player = game:GetService("Players").LocalPlayer
mouse = player:GetMouse()
rs = game:GetService("RunService").RenderStepped
gui = script.Parent
rs:connect(function()
if mouse.Target then
local pos1 = mouse.Target.Position
local pos2 = player.Character.Torso.Position
local magnitude = (pos1 - pos2).magnitude
if magnitude <=33 and mouse.Target and mouse.Target:FindFirstChild("Interact")then
gui.Visible = true
gui.Text = mouse.Target.TextValue.Value
gui.Position = UDim2.new(0,mouse.X+15,0,mouse.Y+15)
else
gui.Visible = false
end
end
end)

3 comments
can't u just use a regular click detector?
If you never knew, CLICK DETECTORS ARE NOT FOR GUIS
What problems did you have when you used magnitude?