I have a MouseoverText LocalScript
, its basically a textlabel
that follows the mouse
when it points to a part, I made a magnitude
for it so you will only see it when youre near it,but its not working, please help me ty
the part 1 of the magnitude is the player head since its a first person game and the part 2 is the mouse target
script:
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local label = script.Parent local target = mouse.Target local range = 10 local head = player.Character:WaitForChild("Head") function updatePos () local X = mouse.X local Y = mouse.Y if target and target:FindFirstChild("MouseoverText") and (head.Position - target.Position).magnitude <= range then label.Position = UDim2.new(0.01,X,0.01,Y) label.Text = target.MouseoverText.Value label.Visible = true else label.Visible = false end end mouse.Move:Connect(updatePos) updatePos()
It's .Magnitude with capital M
You want to update your target variable since it only assign mouse's target at run time, and then never again i suggest you move that varible into the updatePos() function