Number inside table not subtracting properly

I have a dictionary inside a table that consist the name of a plant and its timer (sapling, 3). When I subtract the timer to 1, it subtracts only up to 2.

local sampleTable = {{sapling = 3}}

while wait(5) do
	for i = 1, #plantsTable do
		local item = plantsTable[i]
		for plant, timer in pairs(item) do
			local newTime = timer - 1
			timer = newTime
			print(plant, timer)
		end
	end

end

You aren’t altering the original table if that is what you are trying to do. Instead of timer = newTime maybe you want plantsTable[i][plant] = newTime?

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.