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

How to open a UI when a key is pressed? (SOLVED BY KINGDOM5)

I am trying to make a command bar so you can type commands and run stuff even though you are not the owners. I already got the tween function down but I wanna know how to do the key bind. I used this code

game:service'UserInputService'.InputBegan:connect(function(inputObject, gameProcessedEvent)
	if (inputObject.KeyCode=='W') then
	print'Hi.';
	end;
	end);

1 answer

✓ Accepted answer

Here you go, also your script is full of deprecated ways my man

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer

function InputBegan(input, typing)
	if (input.KeyCode == Enum.KeyCode.W) and not typing then
		GuiObject:Clone().Parent = Player:WaitForChild("PlayerGui")
	end
end

UIS.InputBgan:Connect(InputBegan)

And if you're looking forward to using a more unique way, I recommend learning about ContextActionService

1 comment

0

Nevermind, just realised this was answerd

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