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

How do I make my InventoryGui disappear when my ShopGui appears?

Asked by 7 years ago
Edited 7 years ago

I've been trying for about 30 minutes just to solve this simple problems. The problem is in the Inventory Code section because before, it worked without it. This is the code that I have been using:

----------Title Screen Code----------

wait (0.5)
local TitleScreen = game.Players.LocalPlayer.PlayerGui:WaitForChild("TitleGui")
local TitleFrame = TitleScreen:WaitForChild("TitleFrame")
local TitleButton = TitleFrame:WaitForChild("PlayButton")
local TitleText = TitleFrame:WaitForChild("TitleText")
TitleScreen.Enabled = true

game.Players.playerAdded:connect(function(player)
    TitleScreen.Enabled = true
end)

TitleButton.MouseButton1Down:connect(function(player)
    TitleScreen.Enabled = false
end)

----------Shop Code----------

local ShopScreen = game.Players.LocalPlayer.PlayerGui:WaitForChild("ShopGui")
local ShopFrame = ShopScreen:WaitForChild("ShopFrame")
local ShopButton = ShopScreen:WaitForChild("ShopButton")
local ShopScrollFrame = ShopFrame:WaitForChild("ShopScrollFrame")
local ShopBack = ShopFrame:WaitForChild("BackButton")
ShopScreen.Enabled = false
ShopFrame.Visible = false
ShopButton.Visible = true
ShopScrollFrame.Visible = false
ShopBack.Visible = false

while TitleScreen.Enabled == true do
    wait()
end

if TitleScreen.Enabled == false then
    ShopScreen.Enabled = true
end

ShopButton.MouseButton1Down:connect(function(player)
    ShopButton.Visible = false
    ShopFrame.Visible = true
    ShopScrollFrame.Visible = true
    ShopBack.Visible = true
end)

ShopBack.MouseButton1Down:connect(function(player)
    ShopButton.Visible = true
    ShopFrame.Visible = false
    ShopScrollFrame.Visible = false
    ShopBack.Visible = false
end)

-----------Inventory Code----------

local InvScreen = game.Players.LocalPlayer.PlayerGui:WaitForChild("InventoryGui")
local InvFrame = InvScreen:WaitForChild("InvFrame")
local InvButton = InvScreen:WaitForChild("InvButton")
local InvScrollFrame = InvFrame:WaitForChild("InvScrollFrame")
local InvBack = InvFrame:WaitForChild("BackButton")
InvScreen.Enabled = false
InvFrame.Visible = false
InvButton.Visible = true
InvScrollFrame.Visible = false
InvBack.Visible = false

while TitleScreen.Enabled == true do 
    wait()
end

if TitleScreen.Enabled == false then
    InvScreen.Enabled = true
end

if ShopFrame.Visible == false then
    InvScreen.Enabled = true
end

while InvFrame.Visible == true do
    ShopScreen.Enabled = false
    wait()
end

while ShopFrame.Visible == true do
    InvScreen.Enabled = false
    wait()
end

if InvFrame.Visible == false then
    ShopScreen.Enabled = true
end

InvButton.MouseButton1Down:connect(function(player)
    InvButton.Visible = false
    InvFrame.Visible = true
    InvScrollFrame.Visible = true
    InvBack.Visible = true
end)

InvBack.MouseButton1Down:connect(function(player)
    InvButton.Visible = true
    InvFrame.Visible = false
    InvScrollFrame.Visible = false
    InvBack.Visible = false
end)

It also doesn't say anything in the output. Thanks for the help!

1 answer

Log in to vote
0
Answered by 7 years ago

Try doing something like

if (invFrame.Enabled = true) then
    if (shopFrame.Enabled = true) then
        invFrame.Enabled = false
    end
end

This way when both GUIs are active the inv will disappear but keep in mind just using an if statement will only make it run once so if this should be activated when something happens move it to a function that will detect this trigger, otherwise just put it in a loop of some sort.

0
Thanks! marioblast1244 113 — 7y
Ad

Answer this question