Time is running slow in Tycoon Game

I will start by saying I am not a scripter. My scripter is unavailable at the moment and we are having issue with our tycoon game where in game time is running slow. Basically for every second that passes in game, it takes around 2 - 3 seconds in real life. I have looked for a wait somewhere that could be causing it but I don’t see one anywhere. This is the block of code that lists the rate of pay.

				coroutine.wrap(function()
					while true do	
						if currentDropper:GetAttribute("Boosted") == true and Owns2xCash.Value == true then	
							Cash_To_Collect.Value += CashBasePay * 4
						elseif currentDropper:GetAttribute("Boosted") == true then
							Cash_To_Collect.Value += CashBasePay * 2
						elseif Owns2xCash.Value == true then
							Cash_To_Collect.Value += CashBasePay * 2
						else
							Cash_To_Collect.Value += CashBasePay
						end
						wait(CashPayRate)
					end	
				end)()			
			end)()
		end,

Sorry for the formatting. I’m terrible at this and once again I’m not a scripter but I can understand code fairly well. I don’t know if this snippet helps or not. It’s just such an odd thing. We have a “Time played” counter that also only goes up by 1 second every 2-3 seconds. How do I fix this? Any advice would be great.

This part of the script does not affect the time count.
This affects the Cash to collect.

You can make counter with another script:

local timeValue = ... -- Include here the way to your time value instance

while wait(1) do
	timeValue.Value += 1
end

I appreciate it. I’m a bit lost here and with the scripter unavailable I’ve been trying to figure it out. I’ll mess with it and see if I can get it working myself.

Try this for the coroutine:

coroutine.wrap(function()
	while true do	
		if currentDropper:GetAttribute("Boosted") and Owns2xCash.Value then	
			Cash_To_Collect.Value += CashBasePay * 4
		elseif currentDropper:GetAttribute("Boosted") then
			Cash_To_Collect.Value += CashBasePay * 2
		elseif Owns2xCash.Value then
			Cash_To_Collect.Value += CashBasePay * 2
		else
			Cash_To_Collect.Value += CashBasePay
		end
		
		task.wait(CashPayRate)
	end	
end)()

That seems to work. Thank you for the help.

1 Like

No problem, if you have any more problems, feel free to ask. (Also I used task.wait(n) as it’s more efficient and reliable compared to wait(n). You should use it in your future work.)