Script timeout: exhausted allowed execution time

Hello Developers,


I was testing my game and it was working fine until studio froze and I got this error in the output:

Script timeout: exhausted allowed execution time


I Tried:

  • Restarting Studio.

  • Clearing Storage.

  • Restarting my Whole Computer.

  • Clearing most scripts that are just for details and non-gameplay wise.


Another error I got before this was,

Operation failed. Please check your network connection and try again. If the error persists, contact Customer Support - Studio


Here’s the script I think is causing the freezing and or error. (It’s gameplay wise)

local fader = script.Parent.Parent.fade
local flicker = game.Workspace["Lightbulb Flicker"]
local monster = game.Workspace["Cave Dweller"]
local sniff = game.Workspace.Sniff
local step = game.Workspace.Loud_Step
local creak = game.Workspace["Wood Door Creak Squeak 2 (SFX)"]

task.wait(2.5)

local function typewrite(object,text,length)
	for i = 1,#text,1 do
		local sound = Instance.new("Sound")
		sound.Parent = game.Workspace
		sound.SoundId = "rbxassetid://9120300060"
		sound.Name = "DialogSound"
		sound:Play()
		object.Text = string.sub(text,1,i)
wait(length)		
	end
	for i,v in pairs(game.Workspace:GetChildren()) do
		if v.Name == "DialogSound" then
			v:Destroy()
		end
	end
end

typewrite(script.Parent, "Welcome to your new job.") 
task.wait(4.5)
repeat
	script.Parent.TextTransparency += 0.1
until script.Parent.TextTransparency == 1
task.wait(0.1)
wait(1.5)
script.Parent.TextTransparency = 0
typewrite(script.Parent, "Let's wait for your new friend to arrive.")
task.wait(1)
task.wait(2.5)
repeat
	script.Parent.TextTransparency += 0.1
until script.Parent.TextTransparency == 1
wait(0.5)
repeat 
	fader.BackgroundTransparency += 0.9
until fader.BackgroundTransparency == 0
task.wait(0.1)

if fader.BackgroundTransparency == 0 then
	task.wait(2)
	creak:Play()
	wait(2)
	step:Play()
	wait(1.3)
	step:Play()
	wait(1.7)
	step:Play()
	wait(3)
	sniff:Play()
	wait(2)
	script.Parent.TextTransparency = 0
	typewrite(script.Parent, "He's here...")
	task.wait(4.5)
	repeat
		script.Parent.TextTransparency += 0.1
	until script.Parent.TextTransparency == 1
	wait(1)
	game.workspace["Cave Dweller"]:MoveTo(-55.307, 8.072, -21.427)
	wait(0.6)
	repeat
		fader.BackgroundTransparency += 0.1
		task.wait()
	until fader.BackgroundTransparency == 1
	wait(4)
	repeat
	script.Parent.TextTransparency += 1
	until script.Parent.TextTransparency == 0.1
	wait(0.1)
	typewrite(script.Parent, "Don't be scared. He's friendly.")
	wait(4)
	script.Parent.TextTransparency = 0
	wait(4)
	repeat
		script.Parent.TextTransparency += 1
	until script.Parent.TextTransparency == 0.1
	wait(0.1)
	typewrite(script.Parent, "You're armed. If something goes wrong, which I assure you-")
	wait(0.2)
	script.Parent.TextTransparency = 0
end



(FYI the script is not finished yet.)

attachment

The LocalScript is inside of the Dialogs TextLabel.

I read most of the DevForum posts on this error, for example, Script Timeout: Exhausted Allowed Execution Time Solution #1, but it wasn’t related to my issue. Another solution I explored helped,

This error message indicates that your script in Roblox Studio has exceeded the allowed execution time, which is typically 30 seconds. This can occur if your script is performing a task that is taking too long to complete, or if it is stuck in an infinite loop. To fix this issue, you should review your code to identify any inefficiencies or infinite loops that may be causing the problem. You may also want to consider optimizing your code or breaking up the task into smaller chunks that can be executed in shorter periods of time. Additionally, you may want to adjust your script’s logic to better manage memory usage and reduce the likelihood of timeouts.

but after I came back a while later, it stopped working. I rechecked everything he provided, but it kept giving this error.

One of the reasons I think this is happening is because most of the games mechanics are squished into this one script, or it’s the amount of “repeat until” loops I added. Nonetheless, I’m very new to scripting, so I wouldn’t know. If you find out, please let me know ASAP as there is a deadline on the project I am currently working on. (13hrs left!)

Thanks in advance,

-8ntlers

You aren’t telling the code to wait a certain amount of time, also, use TweenService instead.

2 Likes

Thank you! But sorry, would you care to explain how would I implement TweenService into my code, and where I would tell the script how long to wait?

local TweenService = game:GetService("TweenService") -- Service

local Info = TweenInfo.new(1) -- Creates Info for the tween

TweenService:Create(
script.Parent, -- Object to Tween
Info, -- Tweeninfo
{TextTransparency == 0.1} -- Property to Tween
):Play()

TweenService
Tween

1 Like

Thank you so much! I appreciate it greatly.

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