Title. I have 2 scripts that open a gui. One by pressing G on your keyboard, and by pressing a button. For some weird reason, only the G method works to open the gui.
No errors come out in output. Help.
G script:
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local shopGui = playerGui:WaitForChild("ShopGui")
local imageButton = shopGui:WaitForChild("ImageButton")
local scrollingFrame = shopGui:WaitForChild("Background")
local function toggleVisibility()
scrollingFrame.Visible = not scrollingFrame.Visible
end
imageButton.Activated:Connect(toggleVisibility)
UserInputService.InputBegan:Connect(function(input, processed)
if not processed and input.KeyCode == Enum.KeyCode.G then
toggleVisibility()
end
end)
Button script:
local scrollingframe = script.Parent.Parent. Background
script.Parent.Activated:Connect(function()
scrollingframe.Visible = not scrollingframe.Visible
end)
The g script is located in StarterPlayerScripts
The image script is located in:
The main problem is probably the fact that the button itself is trying to make the Scrolling Frame Visible while the main script is doing the same, so you basically have two scripts countering each other resulting in nothing showing up. My solution would be to delete the Button script entirely.
No im saying, in the G script it looks like you’re already calling the button when it is clicked. Which is fine you can leave that, but the open script in the Button doing the same thing. So if you delete the open script in the button you should be good. Or you could just delete