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

What is TAB in code?keydown Function does not work for me XD

hello

can you please tell me what code/nr is the TAB key im making it so if you press TAB your inventory pops up but i dont know what is the key name you must put in the code

and here is my code i'm using:

local frame = script.Parent:WaitForChild("Frame")
local open = script.Parent.Open
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.KeyDown:connect(function(key)
	if string.lower(key) == "TAB" then
	if open.Value == false then
		frame:TweenPosition(UDim2.new(0.243,0,0.127,0),"Out","Quint",1,true) -- Position of your frame when its opened
		open.Value = true
	elseif open.Value == true then
		frame:TweenPosition(UDim2.new(0.243,0,-0.127,-401),"Out","Quint",1,true) -- Position of your frame when its closed
		open.Value = false
		end
	end
end)

can somebody please tell me

1 answer

✓ Accepted answer

You can use UserInputService

local uis = game:GetService("UserInputService")

uis.InputBegan:connect(function(InputObject)
	
end)

This will give you InputObject

So use InputObject.KeyCode and Enum.KeyCode

local uis = game:GetService("UserInputService")

uis.InputBegan:connect(function(InputObject)
    if InputObject.KeyCode == Enum.KeyCode.Tab then
        print("Tab key pressed")
    end
end)

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