Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Just wondering why my mouse.Target script is not pulling up my GUI?

Asked by 2 years ago
local UIS = game:GetService("UserInputService")

local forageKey = "F"
local eatKey = "E"

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

local PlayerGui = player:WaitForChild("PlayerGui")
local ForageInfoGui = PlayerGui:WaitForChild("ForageInfoGui")
local Foragenoed = PlayerGui:WaitForChild("Foragenoed")

UIS.InputChanged:Connect(function(input)
    if mouse.Target then
        if mouse.Target:FindFirstChild("Edible") then

            local item = mouse.Target
            ForageInfoGui.Adornee = item
            ForageInfoGui.ObjectName.Text = item.Name
            ForageInfoGui.Enabled = true
        else

            ForageInfoGui.Adornee = nil
            ForageInfoGui.Enabled = false   

    if mouse.Target:FindFirstChild("Forage") then

                local item = mouse.Target
                Foragenoed.Adornee = item
                Foragenoed.ObjectName.Text = item.Name
                Foragenoed.Enabled = true

            else

                Foragenoed.Adornee = nil
                Foragenoed.Enabled = false

                    end
                end
            end
        end)

When the item has a bool value called "Forage" it does not work. However, when the item has a bool value called "Edible" it works. Both bool values are enabled and both GUI's are disabled.

Answer this question