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

What happened to my code once I added the Inventory part? Answered

I keep trying to make my Inventory button work, but when ever I press the play button on my Title Screen, it appears for a split second until it disappears. What is happening? This is what I used:

----------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 = 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.Enalbed == false then
	InvScreen.Enabled = true
end

while ShopFrame.Visible == true do
	wait()
end

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

while InvFrame.Visible == true do
	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)

The problem should be somewhere in the Inventory Code area since my code worked before I made that part. Thanks for helping!

3 comments

1

Did you check output for errors? Line 70 says "TitleScreen.Enalbed"..

0

Thanks! I'll see if they fixes everything!

0

Great! It does!

1 answer

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