Im Making Admin For My Game And When You Click On The Admin Button If You Own The gamepass It will Show a gui but its giving me an error Here Is My Script
local passId = 13118751
local player = game.Players.LocalPlayer
local gui = game.Players.LocalPlayer.PlayerGui.AdminGUI
script.Parent.MouseButton1Click:Connect(function()
if game:GetService("MarketplaceService"):PlayerOwnsAsset(game.Players.LocalPlayer.UserId, passId) then
gui.Enabled = true
else
game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, passId)
end
end)
And The Console Says: AdminGUI is not a valid member of PlayerGui "Players.fgtv2222222222222222.PlayerGui"

3 comments
Assets do not load immediately, use :WaitForChild("AdminGui") instead.
Where is your script located? also do, local gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("AdminGUI")
@ninjabyan43 the script is located in game.startergui.admb.localscript