Script Timeout: Exhausted allowed execution time

According to my testing, it’s because of parenting the Map in the workspace. I also said the same thing on the post.

I tried parenting the Map into workspace myself while play-testing, and It made me lag for around 10 to 15 seconds. The issue might just come from my computer, but I doubt it since it worked fine 2 days ago.

What are the contents of CharacterScript? It appears the issue is solely specific to that script, judging by the output you sent.

Would you be able to send the code? Also, I’d recommend copying the code as text instead of an image, and sandwich them between " ``` ".

Example

This:
```
local localPlayer = game:GetService(“Players”).LocalPlayer
print(localPlayer.DisplayName)
```

will become:

local localPlayer = game:GetService("Players").LocalPlayer
print(localPlayer.DisplayName)

This will make it easier for us to test your code since we only have to copy text and not manually type them from screenshots.

The code has 4K lines… I’m making a Robot 64 Fangame that uses the Open Source Robot 64 Engine by zKevin which is why it’s this long.

Are the functions loadmap, teleport, and touched very large (as in more than 100 lines)? Can you send those functions in their entirety instead?

Sure, but how can I make a dropdown message like this? I don’t want to flood the post with all this code.
image

Upon opening a new reply/post, click the cog icon, then “Hide Details”. You can edit the Summary string to change the label, and between the spoiler tags should be the hidden content.

Thanks, here is some samples of the code.

touched

The rest of the touched function is not needed. It just checks for other object types.

function touched(h, rg)
	if h.Parent and h.Parent~=vis and h.Parent.Name~="trs" and not _G.paused then
		if h.Name == "Mid" and not debounce and not swimming and not pole then
			if onrope and h.Parent==onrope then return
			elseif onrope then
				torope(true, onrope)
				local a = CFrame.new(v2(char.Position), v2(h.Position))
				char.CFrame=char.CFrame+a.lookVector*2
				char.Velocity = a.lookVector*v2(char.Velocity).Magnitude
				point = a
			else
				skatestat = {"50-50 Grind", skatestat[2]+50, skatestat[3]+1, true, skatestat[5]}
			end
			torope(nil, h.Parent)
		elseif h.Name == "pole" and not pole and not debounce and not swimming and not hold and not onrope and not wallrun then
			pole = h
			if (v2(char.Position)-v2(pole.Position)).Magnitude>.1 then
				point = CFrame.new(v2(char.Position), v2(pole.Position))-char.Position
			end
			if h:FindFirstChild("finished")then
				h.finished.Value = true
			end
			sliding, longjump, flying, skate, attack, rolling = false, false, false, false, false, false
		elseif h.Name == "jetpack" and not debounce then
			debounce = true
			hasfly = not hasfly
			particle("cloud", 8, true, vis.torso.CFrame)
			_G.health, flying, skate, hasboard, hasflame = 4,false,false,false,false
			if hasfly then  psound(vis.torso, "powerup") end
			wait(1)
			debounce = false
		elseif h.Name == "skateboard" and not debounce then
			debounce = true
			hasboard = not hasboard
			particle("cloud", 8, true, vis.torso.CFrame)
			_G.health, flying, skate, hasfly, hasflame = 4,false,false,false,false
			if hasboard then  psound(vis.torso, "powerup") end
			wait(1)
			debounce = false
		elseif h.Name == "flamethrower"and not debounce then
			debounce = true
			hasflame = not hasflame
			particle("cloud", 8, true, vis.torso.CFrame)
			_G.health, flying, skate, hasboard, hasfly = 4,false,false,false, false
			if hasflame then  psound(vis.torso, "powerup") end
			wait(1)
			debounce = false	
		elseif h.Name == "col"and h:FindFirstChild'tag' then
			local gog = h.CFrame
			local rep, msg, vel = enemies[h.tag.Value][2].touch(mps, (gtick-attacktick)<.2, pound)
			char.Velocity = vel or char.Velocity
			if rep == "damage" and not talkto then
				damage()
			elseif rep == "remove" then

				enemies[msg] = nil
				delay(1,function()
					particle("cloud",1,Vector3.new(),gog)
				end)
			elseif rep == "capture"and not talkto and not char.Anchored then
				char.Anchored = true
				char.CFrame = h.CFrame * CFrame.new(0,1.5,-3.5)
				sliding = false
				dmgtick = gtick
				respawn()
			elseif rep == "beeremove"then
				enemies[msg] = nil
				delay(1,function()
					particle("cloud",1,Vector3.new(),gog)
				end)
			elseif rep == "nospin"then
				attack = false
			end
		elseif (h.Name == "TeleMap" or h:FindFirstChild("TeleMap")) and not debounce and _G.canmove and not talkto then
			
			teleport(h)
loadmap

The rest is not needed since it errors here.

function loadmap(map)
	touchingPart = nil
	_G.loading = true
	print("parenting m")
	map.Parent = workspace
	print("setting variables")
	onrope, pole = nil,nil
	print("setting ignore table")
	ignore = {char, vis, workspace.debris, button, textbox, snapshotcam}
	print("setting tables")
	rg3 = {}
	spinCF = {}
	enemies = {}
	print("setting ring var")
	ring = (map.settings:FindFirstChild("ringNum") and map.settings.ringNum.Value) or ring
	print("end")
	eggs = 0
	maxeggs = 8
	canfloor = true
	_G.gotice = false
	UI.UI.egg.Visible = false
	script.bgm:Stop()script.bgmW:Stop()script.bgmA:Stop()script.bgmC:Stop()
	script.bgm.SoundId = "rbxassetid://"..map.settings.bgm.Value
	script.bgmW.SoundId = map.settings:FindFirstChild'bgmW' and "rbxassetid://"..map.settings.bgmW.Value or "rbxasset://sounds/uuhhh.mp3"
	script.bgmA.SoundId = map.settings:FindFirstChild'bgmA' and "rbxassetid://"..map.settings.bgmA.Value or "rbxasset://sounds/uuhhh.mp3"
	script.bgmC.SoundId = map.settings:FindFirstChild'bgmC' and "rbxassetid://"..map.settings.bgmC.Value or "rbxasset://sounds/uuhhh.mp3"
	script.bgmP.SoundId = map.settings:FindFirstChild'bgmP' and "rbxassetid://"..map.settings.bgmP.Value or "rbxasset://sounds/uuhhh.mp3"
	script.bgm.Volume,script.bgmW.Volume,script.bgmA.Volume,script.bgmC.Volume=0,0,0,0
teleport
function teleport(h, where, mapName)
	debounce = true
	_G.canmove = false
	skate = false
	sliding = false

	if h and h:FindFirstChild'walkto'then
		walkto = h.walkto.Value
	end

	local cpu = false
	if h and h:FindFirstChild'cpu'then
		walkto = -h.cpu.CFrame.LookVector * 0.5
		cpu = true
		lockcam = true
		vcf = h.cpu.CFrame * CFrame.Angles(0,math.pi,0)*CFrame.new(0,0,10)
		char.CFrame = h.CFrame - walkto * 8
		char.Velocity = Vector3.new()
		local t=tick()
		spawn(function()
			while tick()-t<1 do
				local x = 1-(tick()-t)*.8
				scale = Vector3.new(x,x,x)
				wait()
			end end)
		wait(.7)
	end

	transition(true,true)
	wait(.6)
	hold = nil

	local bat = walkto
	walkto = nil
	local oldmap = map
	pheight = nil
	char.Velocity = Vector3.new()
	if where then
		char.CFrame = CFrame.new(where)
	else
		char.CFrame = CFrame.new(h.where.Value)+(h:FindFirstChild'walkto'and h.walkto.Value*16 or Vector3.new())
			+Vector3.new(0,h:FindFirstChild'cpu'and 8 or 0)
	end
	
	safecf = char.CFrame
	scale = Vector3.new(1,1,1)
	pheight = nil
	lockcam = false
	hasboard = false
	hasflame = false
	hasfly = false			
	flying = false
	if h and h:FindFirstChild("tofly")then
		hasfly = true
		flying = true
		pound, sliding, attack, djump, rolling, longjump = false, true, false, true, false, false
	end
	map = rf.maps[mapName or h.to.Value]:Clone()
	oldmap:Destroy()
	
	print("loading map in one second")
	task.wait(1)
	print("loading")
	loadmap(map)

I also noticed that when I load any other map from my game, It doesn’t lag or do anything special. It probably is due to the amount of Decals in the map, I’m gonna try removing some Decals and post the result here (1242 Decals to be exact).

It doesn’t seem there are any issues. Maybe your map is large (in terms of how many instances are in the map). Try using an empty model for the map, see if the error still occurs.

1 Like

After removing all Decals from the map, the game loads just fine. I’m very confused on why it didn’t do this 2 days ago since it had the same amount of Decals, but now I’ll just find a way to add back the Decals without lagging the game. Thanks to everyone that tried to help me, I greatly appeciate it!

Somehow, it doesn’t error anymore. I didn’t change the map nor the CharacterScript in anyway, but it just works now. Might have been a problem related to my computer.

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