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

how can I use keydown to pop up a gui?

I want to make a gui that shows the rules and that etc. But im very confused on this. I know the keydown function (which I cant show at the moment because im using a phone.). But what script should I use for the --code part?

1 answer

✓ Accepted answer

This should be in a LocalScript:

wait()

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local gui = script.Parent --Wherever your GUI is located (This is just for the example)

mouse.KeyDown:connect(function(key)
	if key:lower() == "q" --Just an example key, change to whatever you want
		if gui.Visible == true then
			gui.Visible = false --Makes GUI invisible
		else
			gui.Visible = true --Makes GUI visible
		end
	end
end)

Likewise, if you want to use a special key such as "F4", you'd have to use:

if key:byte() == 29 then
	--Code
end

You can find an entire list of the codes for special characters here:

http://wiki.roblox.com/index.php?title=Taking_keyboard_input

1 comment

0

thanks!

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