Why isn't my script working?

Hello I am trying to get an Image button to make one frame invisible and make another visible but all my script does is make the current frame invisible. I could really use some help.

Script:

script.Parent.MouseButton1Click:Connect(function()

game.StarterGui.InventoryGui.InventoryScreen.Visible = true
script.Parent.Parent.Parent.Visible = false

end)

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.Parent.InventoryScreen.Visible = true
	script.Parent.Parent.Parent.Visible = false
end)
1 Like

That’s because you are making it visible, and then making the SAME gui invisible, so since the last code is making it invisible, it’s invisible.

Edit:
Create a different gui, and then target that.

script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.Parent.InventoryScreenA.Visible = true
script.Parent.Parent.Parent.Parent.InventoryScreenB.Visible = false
end)

1 Like

See responses from others, but also, don’t change things in StarterGui with your script, as that only changes the UI that is put on you when you spawn, not the one that is currently on your screen.

1 Like

Exactly this. Use PlayerGui (game.Players.LocalPlayer.PlayerGui)

1 Like

When you start the game you cant edit starter GUI so you need to use PlayerGUI

1 Like