so I want it so I can hover over a part with my cursor and text appears above my cursor and also, when I go a certain distance away from that part it won't show the text when I hover over it. Sorry, I'm a beginner at scripting.
so how would i make this script not show the text when i am a certain distance away?
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local SHOWGUI = workspace:WaitForChild('PART TEST')
local ScreenGui = script.Parent:WaitForChild('ScreenGuiPart')
local TextLabel = ScreenGui:WaitForChild('TextLabelThing')
game:GetService('RunService').RenderStepped:Connect(function()
local X = Mouse.X
local Y = Mouse.Y
if Mouse.Target then
if Mouse.Target.Name == 'PART TEST' then
TextLabel.Visible = true
TextLabel.Position = UDim2.new(0,X,0,Y + 50)
else
TextLabel.Visible = false
end
end
end)

4 comments
so how would i use the magnitude feature into my code? im kind of a noob
(character.HumanoidRootPart.Position - mouse.Target.Position).magnitude
im sorry if im asking much, but where do i put that in my code? i tried to but i just ended up with nothing
nvm i found the extremely scuffed solution since i dont know how to use magnitude: i just insert a transparent part on top of the part that has the text, so when i go away from the part with the text, my mouse is on the transparent part therefore the text is not shown