#need help with setting a distance limit

2 messages · Page 1 of 1 (latest)

charred vigil
#
Player = Players.LocalPlayer

local Mouse = Player:GetMouse()

function GetName()
    if Mouse.Target:FindFirstChild("Labeled") then
        Player.PlayerGui.GUI.ObjectLabel.Visible = true
        Player.PlayerGui.GUI.ObjectLabel.Text = Mouse.Target.LabelName.Value
        Player.PlayerGui.GUI.ObjectLabel.Position = UDim2.new(0, Mouse.X - 45, 0, Mouse.Y -85)
    elseif Mouse.Target.Parent:FindFirstChild("Labeled") then
        Player.PlayerGui.GUI.ObjectLabel.Visible = true
        Player.PlayerGui.GUI.ObjectLabel.Text = Mouse.Target.Parent.LabelName.Value
        Player.PlayerGui.GUI.ObjectLabel.Position = UDim2.new(0, Mouse.X - 45, 0, Mouse.Y -85)
        Player.PlayerGui.GUI.ObjectLabel.Visible = false
    else
        Player.PlayerGui.GUI.ObjectLabel.Visible = false
    end
end
Mouse.Move:Connect(GetName)```

this script displays a textlabel that sits under your cursor while hovering over a part. how can i set the textlabel invisible if the player is more than x studs away from the part?
kindred zephyr
#

You can get the magnitude and then check if it is farther than you expect