Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why Aren't I Able To Open My GUI?

I've made it a keypressed open/close and it only seems to open in "edit" mode and not in "play" mode.

a = script.Parent.Parent.Shop

game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(Key)
    if Key == "m" then
        a.Visible = not a.Visible
    end
end)

I looked in server console and I saw: Players.cryptomaniacRBLX.PlayerGui.ScreenGui.Shop.Scriptclose:3: attempt to index field 'LocalPlayer'

I have no idea what it means

1 answer

local plr = game.Players.LocalPlayer
plr.PlayerGui:WaitForChild("ScreenGui")
a = plr.PlayerGui.ScreenGui:WaitForChild("Shop")

plr:GetMouse().KeyDown:connect(function(Key)
    if Key == "m" then
        a.Visible = not a.Visible
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.