Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Game script timeout error in random part position spawner?

local bp = game.Workspace.Baseplate
local parts = game.Workspace.Parts.Parts --numbervalue 
local x = bp.Position.X
local xS = bp.Size.X / 2
local y = bp.Position.Y + (bp.Size.Y / 2)
local z = bp.Position.Z
local zS = bp.Size.Z / 2
local eat = game.Workspace.Parts:GetChildren()
limit = 30
balance = 10

while true do
	if parts.Value <= limit then
		print("spawning")
		for i=1,limit do
			touch = script.Touch:Clone()
			local newpart = Instance.new("Part",game.Workspace.Parts)
			newpart.Name = "Eat"
			newpart.Size = Vector3.new(0.6,0.6,0.6)
			newpart.Color = Color3.new(math.random(),math.random(),math.random())
			newpart.Anchored = true
			newpart.FrontSurface = "SmoothNoOutlines"
			newpart.BackSurface = "SmoothNoOutlines"
			newpart.BottomSurface = "SmoothNoOutlines"
			newpart.LeftSurface = "SmoothNoOutlines"
			newpart.RightSurface = "SmoothNoOutlines"
			newpart.TopSurface = "SmoothNoOutlines"
			touch.Parent = newpart
			touch.Disabled = false
			local pos = Vector3.new(math.random(math.min(x - xS), math.max(xS + x)), y, math.random(math.min(z - zS), math.max(zS + z)))
			print(pos)
			newpart.CFrame = newpart.CFrame - newpart.Position + pos
			newpart.Position = newpart.Position + Vector3.new(0,1.85,0)
			parts.Value = parts.Value + 1
			wait(2)
		end
		if parts.Value == limit then
			print("limit")
			wait(balance)
		end
	end
end

My script basically creates a bunch of parts in range of the baseplate. The problem is that the script stops running in between the second loop. The error is "Game script timeout" and I don't know what that means.

3 comments

0

That means the script is running 2 fast for roblox to handle, so it stops the script and puts it in the time out zone.

0

How would you fix this then?

0

^Read my answer

1 answer

✓ Accepted answer

You should always put a wait() in any loop you create. (while true do, for i=1, for i,v in pairs etc.)

That might be the issue!

2 comments

0

not in a while wait() do XD XD XD

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.