I'm trying to make a system where if you hover your mouse over an object, it will display its name on top of your mouse. It's not showing up for me. I'm not using a ClickDetector, and this is a LocalScript.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Tools = game.Workspace.tools:GetChildren() -- Get the tools in the tools folder.
local Doors = game.Workspace.doors:GetChildren() -- Get the doors in the doors folder.
local Tags = {}
local gui = player.PlayerGui:WaitForChild("toolGui")
local label = gui.Label

-- Making the tags table

for i, v in pairs (Doors) do
    table.insert(Tags,v)
end

for i, v in pairs (Tools) do
    table.insert(Tags,v)
end

--Defining the thing for Tags per class

game:GetService("RunService").RenderStepped:Connect(function() --I'll make it run everytime because I don't know any better.
    if mouse.Target then --If I found an object,
	    for i, v in pairs (Tags) do --I will cycle through the Tags table,
		    if v.Name == mouse.Target.Name then --until I found the name of it in the Table itself.
			    print(v)
			    label.Text = v.Name
			    label.Visible = true
			    else --If not, dismiss it.
		    end
	    end
    end
end)

5 comments

0

Two things, what is being printed on output. The else statement on line 28 is unnecessary.

0

hmmm, what's the label's position, maybe it's far away, and is it successufully printing v?

0

enclose the object in a part and name the part the name of the tag

0

@YTRaulByte The output prints out nothing.

0

@starmaq The label's position is exactly how I defined it. It's only like 2 layers anyway. @Fifkee Won't that only work if I put my mouse over the 'part' itself?