Error: (Script timeout: exhausted allowed execution time)

I’m doing something that takes a long time for a script to process and I need the script, not to TimeOut.
when I try to set the Script Timeout I get an error.

Players.ffancyaxax12.PlayerGui.LocalScript:11: attempt to index nil with ‘SetTimeout’

local scriptContext = game:GetService("ScriptContext")

scriptContex:SetTimeout(100)

Even though its on the Roblox DevFourm.

You can only use SetTimeout() in plugins or the command bar. That means Scripts and LocalScripts are not able to call ScriptContext:SetTimeout() at all. Keep that in mind.

You have misspelled your variable name. It’s supposed to be scriptContext:SetTimeout(100), not scriptContex:SetTimeout(100).

You can change the timeout in studio’s settings, it’ll apply to the current place you’re editing:

1 Like

:O, I can only use this in the command bar?

Yes, changing it using the command bar or a plugin has the same effect as changing Roblox Studio’s settings.

Changing it using the devconsole will obviously only apply the changes for that server.

1 Like

Thanks this Worked! :slight_smile: (30 characters)

1 Like

Important to note that changing this setting only applies in studio and the script would exhaust in a live game. Additionally, the dev console command bar is not the same as the studio command bar and attempting to use SetTimeout from the dev console command bar would generate the same permission error as a regular script.

OP did not specify their specific use case, however if the resource intensive operation would need to be completed in a live server, strategically adding wait()s would allow the function to continue, and would minimize the impact on the server’s responsiveness. Not yielding during any resource intensive operation (i.e map load) can cause the server to become unresponsive until the operation completes.

2 Likes

Ah. I thought DevConsole commands would be considered command bar commands. Thanks for the correction.

1 Like