Os.time not working the way I want

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

Try this.

os.time is for 1 second increments (so calling it in the same second returns the same value), I’d recommend using os.clock because it’s more precise.

Ight I tried this and still not working. In the output I’m getting
OSTIME 202181.3444479
TIME SINCE PRESSED 202181.3441771
AFTER MATH 0.0008193000103347

This is because you’re probably resetting the TIME index every heartbeat by indexing and changing it. Please explain what Queue:push is (preferably the code associated with it).

Not sure if this helps, but this is the code for it

function fifo:push ( v )
	self.tail = self.tail + 1
	self.data[self.tail] = v
end

v equals this {[“INPUT”] = “Left”, [“TIME”] = 202659.7265689}