Inventory Not Opening

(New to scripting)
My goal is to make a inventory and when i click the “PartButton”, a part will spawn. but, the inventory will not open.

:green_square:-- Close Button Script:

local ImageButton = script.Parent
local PartButton = script.Parent.Parent.ImageButton
local InvText = script.Parent.Parent.InvText
local Frame = script.Parent.Parent.Parent.Frame

local colorNormal = Color3.new(1, 1, 1)
local colorHover = Color3.new(0.533333, 0.533333, 0.533333)
local colorPress = Color3.new(0.101961, 1, 0)

local function OnActivated()
ImageButton.ImageColor3 = colorPress
wait()
ImageButton.Active = false
ImageButton.ImageTransparency = 1
PartButton.Active = false
PartButton.ImageTransparency = 1
InvText.Transparency = 1
InvText.TextTransparency = 1
Frame.Transparency = 1

end
local function OnHover()
ImageButton.ImageColor3 = colorHover
end
local function OnLeave()
ImageButton.ImageColor3 = colorNormal
end

ImageButton.MouseEnter:Connect(OnHover)
ImageButton.MouseButton1Down:Connect(OnPress)
ImageButton.MouseButton1Up:Connect(OnLeave)
ImageButton.Activated:Connect(OnActivated)

:green_square:–Backpack Open Script

local SGui = game:GetService(“StarterGui”)
local imageButton = script.Parent

local colorNormal = Color3.new(1, 1, 1)
local colorHover = Color3.new(0, 1, 0) – green
local colorPress = Color3.new(1, 0, 0) – red

local ImageButton = SGui.Inventory.Frame.Close
local PartButton = SGui.Inventory.Frame.ImageButton
local InvText = SGui.Inventory.Frame.InvText
local Frame = SGui.Inventory.Frame

local function OnActivated()
wait()
ImageButton.Active = true
ImageButton.ImageTransparency = 0
PartButton.Active = true
PartButton.ImageTransparency = 0
InvText.Transparency = 0
InvText.TextTransparency = 0
Frame.Transparency = 0
end

local function OnPressed()
imageButton.ImageColor3 = colorPress
end

local function OnReleased()
imageButton.ImageColor3 = colorHover
end

local function OnEntered()
imageButton.ImageColor3 = colorHover
end

local function OnLeft()
imageButton.ImageColor3 = colorNormal
end

imageButton.Activated:Connect(OnActivated)
imageButton.MouseEnter:Connect(OnEntered)
imageButton.MouseLeave:Connect(OnLeft)
imageButton.MouseButton1Down:Connect(OnPressed)
imageButton.MouseButton1Up:Connect(OnReleased)

1 Like

I’m not for sure, but try setting SGui to PlayerGui instead of StarterGui. I believe this will work since the one you’re targeting isn’t the players.

1 Like

When you are playing the game, the gui is moved from startergui to playergui.
this line “local SGui = game:GetService(“StarterGui”)” should be
local p = game.players.localplayer
local SGui = p.playergui

3 Likes