The os.time() that gets put into the table for some reason is exactly the same as the os.time() in the check so the result is always 0
Main.UIS.InputBegan:Connect(function(inputObj, processed)
if processed then end
--get our command input
local Key = Main.UIS:GetStringForKeyCode(inputObj.KeyCode)
if CommandInputs[Key] then
local input = CommandInputs[Key]
--push our input to the queue
Queue:push({INPUT = input, TIME = os.time()})
end
end)
--All of this code is inside a function which is being ran by heartbeat
warn("OSTIME "..os.time()) --equals like 16236153etc
warn("TIME "..obj["TIME"]) --equals the same as above
warn(os.time() - obj["TIME"]) --always equals 0 because the 2 things both for some reason equals the same thing
if ((os.time() - obj["TIME"]) > 0.5) then
warn("Expired")
Queue:remove(i) --removes the old input
return -- sometimes the object returned from Queue:peek() is nil
I tried making a simpler version of the code above and it seems to work just fine so I’m not sure why the one above isn’t working
local UIS = game:GetService("UserInputService")
local Table = {}
UIS.InputBegan:Connect(function(Input,GP)
if GP then return end
local Key = UIS:GetStringForKeyCode(Input.KeyCode)
Table = {TIME = os.time()}
warn(Table["TIME"])
end)
while wait() do
if Table["TIME"] then
warn(os.time() - Table["TIME"])
if ((os.time() - Table["TIME"]) > 0.5) then
warn("Expire")
end
end
end