Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
1
Answered by
OnaKat 444 Moderation Voter
5 years ago
Edited 5 years ago

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)
Ad

Answer this question