Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make it that i can press the letter X and it will open the shop?

Sorry im new to scripting and i just really need help

local Button = script.Parent
Box = script.Parent.Parent.Box

function onClick()
	if Box.Visible == false then
		Box.Visible = true
		Button.Text = "CLOSE"
	elseif Box.Visible == true then
		Box.Visible = false
		Button.Text = "SHOP"
	end
end

Button.MouseButton1Click:connect(onClick)

I didnt attempt to do it yet because i have no idea how, please help

1 answer

Try using UIS

local UIS = game:GetService("UserInputService")
local btn = script.Parent

local box = script.Parent.Parent.Box

UIS.InputBegan:Connect(function(input)
	if input.KeyCode = Enum.KeyCode.X then
		if box.Visible == false then
			box.Visible = true
			btn.Text = "Close"
		elseif box.Visible == true then
			box.Visible = false
			button.Text = "Shop"
		end
	end
end

Then put the mousebutton1click code below. Hope this helped!

This discussion is preserved as it was. New answers, comments, and votes are closed.