Alright so I made a Key Pressing Script using UserInputService.
local UIS = game:GetService('UserInputService') local player = game.Players.LocalPlayer local shop = script.Parent.Parent:WaitForChild('PlayerGui').ShopGui UIS.InputBegan:connect(function(InputObject) if InputObject.KeyCode == Enum.KeyCode.X then shop.Background.Visible = true print('X was pressed') end end)
Quick fix I found to your problem.
local UIS = game:GetService('UserInputService') local player = game.Players.LocalPlayer UIS.InputBegan:connect(function(InputObject) local shop = script.Parent.Parent:WaitForChild('PlayerGui').ShopGui if InputObject.KeyCode == Enum.KeyCode.X then shop.Background.Visible = true print('X was pressed') end end)
I moved the shop variable into the InputBegan function so it checks it once you have clicked a key.
If this helped make sure to Accept the Answer