When using :IsKeyDown the result returned is not always correct. As you will see from this example below, the key has clearly been released but IsKeyDown still returns true.
inputService = game:GetService'UserInputService'
inputService.InputBegan:connect(function (input)
if input.UserInputType == Enum.UserInputType.Keyboard then
repeat
local output = inputService.InputEnded:wait()
until input.KeyCode == output.KeyCode
print(inputService:IsKeyDown(input.KeyCode)
end
end)
>> True
This is beside the point. It’s not very useful if you have to wait a frame, that would cause input lag. I get around this myself by creating a table for keys that are pressed and setting it as soon as InputBegan or InputEnded is fired.
Maybe when you release the key, events are fired before the IsKeyDown’s internal table is altered.
(In that case, try coroutine.yield(), as that would yield, but like a 1/1000th of what wait() would yield for)