Script timeout: exhausted allowed execution time

i dont know why im running into this error, but i dont know how to fix it

can someone help?

while true do
	-- core overheating section
	if workspace.Values.TemperatureSystem.Temperature.Value > 13950 then
		workspace.Sounds.OverheatAlarm.Playing = true
		game:GetService("TweenService"):Create(workspace.Map.Alarms.OverheatAlarm.Alarm, TweenInfo.new(0.1), {Color = Color3.fromRGB(255, 255, 0)}):Play()
		wait(0.698)
		game:GetService("TweenService"):Create(workspace.Map.Alarms.OverheatAlarm.Alarm, TweenInfo.new(0.1), {Color = Color3.fromRGB(27, 42, 53)}):Play()
		wait(0.698)
	else
		if workspace.Map.Alarms.OverheatAlarm.Alarm.Color ~= Color3.fromRGB(24, 42, 53) then
			game:GetService("TweenService"):Create(workspace.Map.Alarms.OverheatAlarm.Alarm, TweenInfo.new(0.1), {Color = Color3.fromRGB(27, 42, 53)}):Play()
			continue
		end
	end
	task.wait()
end

I don’t think it’ll fix it, but try this:

while task.wait(0.001) do
	-- core overheating section
	if workspace.Values.TemperatureSystem.Temperature.Value > 13950 then
		workspace.Sounds.OverheatAlarm.Playing = true
		game:GetService("TweenService"):Create(workspace.Map.Alarms.OverheatAlarm.Alarm, TweenInfo.new(0.1), {Color = Color3.fromRGB(255, 255, 0)}):Play()
		task.wait(0.7)
		game:GetService("TweenService"):Create(workspace.Map.Alarms.OverheatAlarm.Alarm, TweenInfo.new(0.1), {Color = Color3.fromRGB(27, 42, 53)}):Play()
		task.wait(0.7)
	elseif workspace.Map.Alarms.OverheatAlarm.Alarm.Color ~= Color3.fromRGB(24, 42, 53) then
		game:GetService("TweenService"):Create(workspace.Map.Alarms.OverheatAlarm.Alarm, TweenInfo.new(0.1), {Color = Color3.fromRGB(27, 42, 53)}):Play()
		continue
	end
end

Probably isn’t gonna work at all now that I think about it :laughing:

you were right :+1: , error just changes to line 11

edit: nvm i changed the wrong script, testing now

The issue may be because you put continue at the end of the last if statement, which does not have any yields. continue skips the following code, which would skip the task.wait() at the end. That if statement is probably getting ran a lot at once, possibly causing the problem – there are no yields.

1 Like

Something you can do to fix this would be to just have the while loop condition be similar to the following instead of just making it true

while task.wait() do
     -- code
end

his solution worked, ill try yours now and see which one is efficient

error is gone, but i havent reached the testing part (takes time)

yours was alot simpler, ill mark it as solution because

im a beginner, so its friendly to me

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