Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Game script timeout error in random part position spawner?

Asked by 6 years ago
Edited 6 years ago
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.

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. hiimgoodpack 2009 — 6y
0
How would you fix this then? InfernoExeuctioner 126 — 6y
0
^Read my answer Nowaha 459 — 6y

1 answer

Log in to vote
0
Answered by
Nowaha 459 Moderation Voter
6 years ago

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!

0
not in a while wait() do XD XD XD greatneil80 2647 — 6y
0
Thanks! InfernoExeuctioner 126 — 6y
Ad

Answer this question