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

Help With Key Byte?

local Mouse = game.Players.LocalPlayer:GetMouse() bin = script.Parent

Mouse.KeyDown:connect(function(Key) if Key:lower() == "enter" then bin:CaptureFocus() end end)

-- I know I have this wrong but I'm not sure how to make it so when u press enter it will capture focus Help!?!?

2 comments

0

Please put the script in a code block.

0

@iiNemo, come look at my script again, I edited it.

2 answers

There isn't really a way to check if a player pressed the enter button according to this chart. You could also do

string.byte(key) == 27 then --27 is the escape key on the keyboard.

But you can't really do an enter key.

EDIT

I just learned what Device Control is. The code for enter is 13.

string.byte(key) == 13 then --13 is the enter key on the keyboard.

2 comments

0

Ik the codes but thanks for the info that I can't use the enter key that saved my time

0

Your welcome.

I don't know about what Lord said, but im pretty sure you can use the enter key. Do it like this and it will work

Mouse.KeyDown:connect(function(Key) 
	
	if Key:byte() == 13 then 
		bin:CaptureFocus() 
	end 

end)

Some keys dont have a string value, which is what :lower() if for. You can use :byte() for the number, so for this example, 13 = enter.

Good luck with it!

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