Need Help with this debounce. Cant find anything on it

While i was making a tycoon i ran into a bug that i know why its happening but i dont know how to fix it.
Whats happening is when the Specific part touches the Sell Part it Deletes the Part then give the player +5 Cash… but its not doing that exact part… Instead its working for a little then stops decting the Touch Event…
here is the Script

module.Sell = function(player, Folder)
	
	local Time = time()
	
	Folder.FirstFloor.SellPart.Touched:Connect(function(hit)
		if hit:GetAttribute("Item") == "IsItem" then
			if (time() - Time) > 1 then
				Time = time()
				player.PlayerFolder.ATMCASH.Value += hit:GetAttribute("Gain")
				hit:Destroy()
			end
		end
	end)
	
end

then heres a video of whats happening in the script.

im guessing the Debounce is not correct

Os.time(), tick() or time()? u should try using os.time

i just tried it but im getting the same probelm sadly
i got no idea why this is happening.

module.Sell = function(player, Folder)
	local Time = os.time()
	
	Folder.FirstFloor.SellPart.Touched:Connect(function(hit)
		if hit:GetAttribute("Item") == "IsItem" then
			if (os.time() - Time) > 1 then
				Time = os.time()
				player.PlayerFolder.ATMCASH.Value += hit:GetAttribute("Gain")
				hit:Destroy()
			end
		end
	end)
	
end

Nvm I fixed it my bad its really late at night so my apologies :slight_smile:

1 Like