I know how it would be for as long as you keep a key pressed to execute an action but I do not know how it would do so that when you finish holding down a key for Z seconds. Help me
Example of what I did : local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input,obj)
local key = input.KeyCode
if key == Enum.KeyCode.E and not obj then
script.Parent.Frame:TweenSize(UDim2.new(0, 546,0, 43),"InOut","Linear",8,true)
script.Parent.Frame.Visible = true
script.Parent.Frame2.Visible = true
end
end)
Instead of InputBegan use InputEnded with similar parameters as InputBegan
Example:
local uis = game:GetService("UserInputService") uis.InputEnded:Connect(function(input, obj) local key = input.KeyCode local NotKey = Enum.KeyCode.Z --Replace Z with the key you want to check is not pressed after the amount of seconds if key == Enum.KeyCode.E and not obj then wait() --Put in number of seconds you want to wait for if uis:IsKeyDown(NotKey) then -- If whatever key you chose is not pressed after the amount of time you put then --Code end end end)