MouseEnter function not working

So I’m trying to make a script that shows a little description on the brick that the mouse is hovering over. I get an error and I can’t quite find a solution as to how I can fix my code.

Code:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
local mouse = player:GetMouse()

lookTableNames = {workspace:WaitForChild("BedLookPart"),workspace:WaitForChild("ClockLookPart")}

local function showDescription(plr,part)
	if hrp.Anchored == false then
		print("debug3")
		local bill = part:FindFirstChild("BillboardGui")
		bill.Enabled = true
		part.MouseLeave:Connect(function()
			bill.Enabled = false
		end)
	end
end

for _, part in pairs(workspace:GetChildren()) do
	if table.find(lookTableNames,part) then
		print("debug1")
		part.MouseEnter:Connect(function()
			print("debug2")
			showDescription(game.Players.LocalPlayer, part)
		end)
	end
end

Only the first debug message works

Error:
image

Based off what I’m seeing I would say the part you’re referencing doesn’t have .MouseEnter as an event, which would give you that error.

MouseEnter method is for buttons only not parts.

You can try to get the mouse on the client side and use mouse.Target to check the part then show the information of the part.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.