So, I am having an issue with guis not turning visible/invisible in game. I have a keybind event that looks like this
local gui = game:GetService("StarterGui") local shop = gui.shopgui.Frame -- The name of the shop frame local mouse = game.Players:GetMouse() local toggle = false mouse.KeyDown:Connect(function(key) if key == "m" then if toggle == false then shop.Visible = true toggle = true elseif toggle == true then shop.Visible = false toggle = false end end end end)
Although, while im in studio and playing the game I can see the property of the gui and it says its visible but it doesn't show in the game screen. Help would be appreciated. Ask any questions about this if you have trouble understanding.
local gui = game:GetService("StarterGui") local shop = gui.shopgui.Frame -- The name of the shop frame local mouse = game.Players:GetMouse() local toggle = false mouse.KeyDown:Connect(function(key) if key == "m" then if toggle == false then shop.Visible = true elseif toggle == true then shop.Visible = false end end end end)
Try This without the toggle = true & toggle = false
Use the InputBegan event in UserInputService instead of the KeyDown event.
local UIS = game:GetService("UserInputService") local shop = script.Parent -- Put this script in the GUI local toggle UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.M then -- checks if the key that fired the event was "M" if toggle then -- checks if the debounce is true shop.Visible = false -- if true then sets the visibility to false and db to false toggle = false else shop.Visible = true -- if false then sets the visibility to true and db to true toggle = true end end end)