I am a beginner scripter and I am trying to make a shop GUI. I have added an ImageButton with the following script:
local button = script.Parent
local shopgui = game.StarterGui.ShopGUI.Frame
button.MouseButton1Click:Connect(function()
if button.Image == 2596564913 then
shopgui.Visible = false
end
shopgui.Visible = true
button.Image = 2596564913
end)
I am wondering why it doesn't work. It is supposed to change the image to an X symbol. The if statement is supposed to check if the image is the X, then to close the Shop GUI.
However, when I playtested, I clicked on the shop icon and it just turned the image blank, and didn't even open the GUI. I've tried adding "else" to it, but it doesn't work either.
All help is appreciated :)

5 comments
Try to use print() statements. They help alot. Then tell me the results.
So, I added print("Shop Closed") inside the if statement and print("Shop Opened") under the if statement. I ran the game, clicked the button but still got no result.
I think you gotta do "rbxassetid://2596564913" make sure it's a string in your script
again, you're trying to change the startergui, which obviously won't work. change the playergui instead. @TheBravestRobloxian
also, like what @MarkedTomato said, you need to get the rbxassetid of an image id