#How to wait for input
9 messages · Page 1 of 1 (latest)
you can probably store last key press to a variable
last key release*
and every heartbeat check the difference
this should work
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local lastRelease = 0
local isHolding = false
local MAX_TIME = 3 -- 3 seconds
UserInputService.InputEnded:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.E then
lastRelease = os.clock()
isHolding = false
end
end)
UserInputService.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.E then
isHolding = true
end
end)
RunService.Heartbeat:Connect(function()
if lastRelease ~= 0 and not isHolding and os.clock() - lastRelease > MAX_TIME then
print("too much time passed!!")
end
end)```
theres probably a simpler way but eh
damn u wrote me the entire code lol
eh thats the most accurate way