BillboardGui Enabled problem

I am making an inventory system, and I have made this script:
local UIS = game:GetService(“UserInputService”)
local PickupKey = “F”

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local PlayerGui = player:WaitForChild(“PlayerGui”)
local PickupInfoGui = PlayerGui:WaitForChild(“PickupInfoGui”)

UIS.InputChanged:Connect(function(input)
if mouse.Target then
if mouse.Target:FindFirstChild(“Pickable”) then
local item = mouse.Target
PickupInfoGui.Adornee = item
PickupInfoGui.ObjectName.Text = item.Name
PickupInfoGui.Enabled = true
else
PickupInfoGui.Adornee = nil
PickupInfoGui.Enabled = false
end
end
end)
The script should make it so it only is Enabled if you hover over the part.
But instead, it does nothing.

try using the mouse.Moved event instead

1 Like

Alright, sounds good. I will try it out.

1 Like

Confirmation-
Did you mean change local item = mouse.Target to local item = mouse.Moved?
If so, it did not work.

Actually use the run service instead, because the mouse.moved event will not working if the player’s camera moves and the mouse does not:

local RunService = game:GetService("RunService")

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local PlayerGui = player:WaitForChild(“PlayerGui”)
local PickupInfoGui = PlayerGui:WaitForChild(“PickupInfoGui”)

RunService.Heartbeat:Connect(function()
    if mouse.Target then
        if mouse.Target:FindFirstChild(“Pickable”) then
            local item = mouse.Target
            PickupInfoGui.Adornee = item
            PickupInfoGui.ObjectName.Text = item.Name
            PickupInfoGui.Enabled = true
        else
            PickupInfoGui.Adornee = nil
            PickupInfoGui.Enabled = false
        end
    end
end)

In the future please upload your code properly.

Alright! Thanks for the advice!