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

Weird For Loop Timeout Error (Possible Engine Bug?)

Asked by 4 years ago

Before I ramble on about this, I asked around in the Scripting Helpers Discord, and I had a few people mention this might be a Engine bug as this should not be timing out. When I first scripted this about 2 weeks+ back, it worked 100% flawlessly, now that I come back to work on it, I'm getting this timeout error.

Anyways, about the script, It's a simple player join script. Under the join script I have all the values I need it to create, since I'm creating a form of a tech tree for my game, and a resources folder. Hard to explain, but this picture would better represent. You'd also need to see the image to somewhat understand the code. I know there's other ways to do this better, but I just want to do this my way, you know? Image

I'm not sure how to further explain this, so here's the code. It times out on line 90, which would be the second for loop.

    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = plr

    local Cash = Instance.new("IntValue")
    Cash.Name = "Cash"
    Cash.Parent = leaderstats

    local TechTree = Instance.new("Folder")
    TechTree.Name = "PlayerTechTree"
    TechTree.Parent = plr

    local Resources = Instance.new("Folder")
    Resources.Name = "PlayerResources"
    Resources.Parent = plr

    for _,v in pairs (script.TechTree:GetChildren()) do
        local a = v:Clone()
        a.Parent = TechTree
    end

    for _,v in pairs (script.Resources:GetChildren()) do
        local a = v:Clone()
        a.Parent = Resources
    end

1 answer

Log in to vote
0
Answered by 4 years ago

Update, I fixed it. I simply just rewrote the a.Parent = TechTree (and the other one) to a.Parent = plr.PlayerTechTree and plr.PlayerResources. I however still wander if this is a engine bug, since, as I stated, worked flawlessly before.

Ad

Answer this question