Hi there, I’m trying to make a script where if the player presses TAB or interacts with a proximity prompt (TabletProximityPrompt), a GUI would pop up. Pressing a textbutton (XButton) would close it but it’s not really working… Not sure what the issue is.
Here’s the spaghetti code inside a LocalScript (I must say I apologize for any dumb mistakes, I’m new to scripting):
local ShopGUI = script.Parent.ShopGUI
local TabletProximityPrompt = script.Parent.proximity.TabletProximityPrompt
local XButton = ShopGUI.XButton
local hidden = true
local function showShopGUI()
for _, child in ipairs(ShopGUI:GetChildren()) do
child.Transparency = 0
end
hidden = false
end
local function hideShopGUI()
for _, child in ipairs(ShopGUI:GetChildren()) do
child.Transparency = 1
end
hidden = true
end
game.Players.LocalPlayer.KeyDown:connect(function(key)
if key == Enum.KeyCode.Tab and hidden then
showShopGUI()
end
end)
TabletProximityPrompt.Interacted:connect(function()
if hidden then
showShopGUI()
end
end)
XButton.MouseButton1Click:connect(hideShopGUI)
Thanks in advance!