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

"Attempt to index nil with enabled?"

Asked by
0te 35
3 years ago
local Inventory = game.Players.LocalPlayer.PlayerGui:findFirstChild("Inventory")
local Shop = game.Players.LocalPlayer.PlayerGui:findFirstChild("Shop")

function openShop()
    Inventory.Enabled = false
    Shop.Enabled = true
end

script.Parent.Frame.Shop.MouseButton1Click:connect(openShop)

Inventory and Shop are both ScreenGuis

For some reason there's an error on the "Inventory.Enabled = false" and I'm not sure why.

0
try enabling visible on a frame inside inventory cjkizzy286 40 — 3y
0
Tried it but unfortunately it didn't work 0te 35 — 3y

2 answers

Log in to vote
0
Answered by
FirezDevv 162
3 years ago

The first thing I see is to try to change findFirstChild to FindFirstChild

I find that if you mess up a capitalization it can error the script completely so try this and tell me your result

Here is the updated script.

local Inventory = game.Players.LocalPlayer.PlayerGui:FindFirstChild("Inventory")
    local Shop = game.Players.LocalPlayer.PlayerGui:FindFirstChild("Shop")

    function openShop()
        Inventory.Enabled = false
        Shop.Enabled = true
    end

    script.Parent.Frame.Shop.MouseButton1Click:connect(openShop)
0
I tried this too but I still am getting the same error. Thank you for your help though. 0te 35 — 3y
0
I seriously don't know why, make sure nothing else is named the same. FirezDevv 162 — 3y
Ad
Log in to vote
0
Answered by
0te 35
3 years ago

Found the solution. It was because the localscript was inside a screengui instead of directly under "StarterGui".

Answer this question