local player = game.Players.LocalPlayer local mouse = player:GetMouse() target = mouse.Target local billboard while true do if target.Parent == game.Workspace.Items then billboard = mouse.Target.BillboardGui billboard.Enabled = true print("Mouse hovering over food") else billboard.Enabled = false end wait(.1) end
target is fine, but target.Parent isn't why not?
local script in starter pack
Your target is coming up nil because you're only checking for the mouse target as the script is loading so it is never actually updating what the mouse is targeting. Try something like this:
local player = game.Players.LocalPlayer local mouse = player:GetMouse() while true do local target = mouse.Target --Mouse target will update at the start of every loop if target ~= nil and target.Parent == game.Workspace.Items then --Makes sure the target isn't nil such as aiming the mouse at the sky billboard = mouse.Target.BillboardGui target.BillboardGui.Enabled = true print("Mouse hovering over food") else if billboard ~= nil then --Makes sure the script doesn't error should the billboard not exist billboard.Enabled = false end end wait(.1) end