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

Problem with the creation of the world why?

Asked by 5 years ago

This script outputs:

Workspace.GeneratedWorld1.Scripts.SpreadBioms:13: attempt to index field 'Parent' (a nil value)

wait (10)
wait()
while true do
wait ()
if game.Workspace.GeneratedWorld1.Values.SpreadBioms.Value == true then
local LocalTransparency = 0

local descendants = game.Workspace:GetDescendants()
for index, descendant in pairs(descendants) do

    if descendant.Name == "BiomCenter" then
        print (descendant.Name)
        print (descendant.Parent.Name)
        if descendant.Parent.BiomIsSpread.Value == false and descendant.Name == "BiomCenter" then
    ----[1]----
        local found = descendant.Parent.Parent:FindFirstChild(descendant.Parent.ZName.Value..","..descendant.Parent.XName.Value)
        if found then
            local BiomFields = game.Lighting.BiomeFields:GetChildren()
            local ChoosenField = game.Lighting.BiomeFields:FindFirstChild(math.random(1, #BiomFields))
            local FieldCloner = ChoosenField:Clone()
            FieldCloner.Parent = game.Workspace.GeneratedWorld1.Fields
            FieldCloner.Name = (found.ZName.Value..","..found.XName.Value)
            FieldCloner:SetPrimaryPartCFrame(CFrame.new(found.PositionX.Value,found.PositionY.Value,found.PositionZ.Value))
            FieldCloner.PositionX.Value = found.PositionX.Value
            FieldCloner.PositionZ.Value = found.PositionZ.Value
            FieldCloner.PositionY.Value = found.PositionY.Value
            FieldCloner.XName.Value = found.XName.Value
            FieldCloner.ZName.Value = found.ZName.Value
        end
        wait (0.01)
    ----[2]----
        local found = descendant.Parent.Parent:FindFirstChild(descendant.Parent.ZName.Value + 1 ..","..descendant.Parent.XName.Value)
        if found then
            local BiomFields = game.Lighting.BiomeFields:GetChildren()
            local ChoosenField = game.Lighting.BiomeFields:FindFirstChild(math.random(1, #BiomFields))
            local FieldCloner = ChoosenField:Clone()
            FieldCloner.Parent = game.Workspace.GeneratedWorld1.Fields
            FieldCloner.Name = (found.ZName.Value..","..found.XName.Value)
            FieldCloner:SetPrimaryPartCFrame(CFrame.new(found.PositionX.Value,found.PositionY.Value,found.PositionZ.Value))
            FieldCloner.PositionX.Value = found.PositionX.Value
            FieldCloner.PositionZ.Value = found.PositionZ.Value
            FieldCloner.PositionY.Value = found.PositionY.Value
            FieldCloner.XName.Value = found.XName.Value
            FieldCloner.ZName.Value = found.ZName.Value
            found:Destroy()
        end
        wait (0.01)
    ----[3]----
        local found = descendant.Parent.Parent:FindFirstChild(descendant.Parent.ZName.Value - 1 ..","..descendant.Parent.XName.Value)
        if found then
            local BiomFields = game.Lighting.BiomeFields:GetChildren()
            local ChoosenField = game.Lighting.BiomeFields:FindFirstChild(math.random(1, #BiomFields))
            local FieldCloner = ChoosenField:Clone()
            FieldCloner.Parent = game.Workspace.GeneratedWorld1.Fields
            FieldCloner.Name = (found.ZName.Value..","..found.XName.Value)
            FieldCloner:SetPrimaryPartCFrame(CFrame.new(found.PositionX.Value,found.PositionY.Value,found.PositionZ.Value))
            FieldCloner.PositionX.Value = found.PositionX.Value
            FieldCloner.PositionZ.Value = found.PositionZ.Value
            FieldCloner.PositionY.Value = found.PositionY.Value
            FieldCloner.XName.Value = found.XName.Value
            FieldCloner.ZName.Value = found.ZName.Value
            found:Destroy()
        end
        wait (0.01)
    ----[4]----
        local found = descendant.Parent.Parent:FindFirstChild(descendant.Parent.ZName.Value ..","..descendant.Parent.XName.Value + 1)
        if found then
            local BiomFields = game.Lighting.BiomeFields:GetChildren()
            local ChoosenField = game.Lighting.BiomeFields:FindFirstChild(math.random(1, #BiomFields))
            local FieldCloner = ChoosenField:Clone()
            FieldCloner.Parent = game.Workspace.GeneratedWorld1.Fields
            FieldCloner.Name = (found.ZName.Value..","..found.XName.Value)
            FieldCloner:SetPrimaryPartCFrame(CFrame.new(found.PositionX.Value,found.PositionY.Value,found.PositionZ.Value))
            FieldCloner.PositionX.Value = found.PositionX.Value
            FieldCloner.PositionZ.Value = found.PositionZ.Value
            FieldCloner.PositionY.Value = found.PositionY.Value
            FieldCloner.XName.Value = found.XName.Value
            FieldCloner.ZName.Value = found.ZName.Value
            found:Destroy()
        end
        wait (0.01)
    ----[5]----
        local found = descendant.Parent.Parent:FindFirstChild(descendant.Parent.ZName.Value ..","..descendant.Parent.XName.Value - 1)
        if found then
            local BiomFields = game.Lighting.BiomeFields:GetChildren()
            local ChoosenField = game.Lighting.BiomeFields:FindFirstChild(math.random(1, #BiomFields))
            local FieldCloner = ChoosenField:Clone()
            FieldCloner.Parent = game.Workspace.GeneratedWorld1.Fields
            FieldCloner.Name = (found.ZName.Value..","..found.XName.Value)
            FieldCloner:SetPrimaryPartCFrame(CFrame.new(found.PositionX.Value,found.PositionY.Value,found.PositionZ.Value))
            FieldCloner.PositionX.Value = found.PositionX.Value
            FieldCloner.PositionZ.Value = found.PositionZ.Value
            FieldCloner.PositionY.Value = found.PositionY.Value
            FieldCloner.XName.Value = found.XName.Value
            FieldCloner.ZName.Value = found.ZName.Value
            found:Destroy()
        end
        wait (0.01)
    ----[6]----
        local found = descendant.Parent.Parent:FindFirstChild(descendant.Parent.ZName.Value + 1 ..","..descendant.Parent.XName.Value + 1)
        if found then
            local BiomFields = game.Lighting.BiomeFields:GetChildren()
            local ChoosenField = game.Lighting.BiomeFields:FindFirstChild(math.random(1, #BiomFields))
            local FieldCloner = ChoosenField:Clone()
            FieldCloner.Parent = game.Workspace.GeneratedWorld1.Fields
            FieldCloner.Name = (found.ZName.Value..","..found.XName.Value)
            FieldCloner:SetPrimaryPartCFrame(CFrame.new(found.PositionX.Value,found.PositionY.Value,found.PositionZ.Value))
            FieldCloner.PositionX.Value = found.PositionX.Value
            FieldCloner.PositionZ.Value = found.PositionZ.Value
            FieldCloner.PositionY.Value = found.PositionY.Value
            FieldCloner.XName.Value = found.XName.Value
            FieldCloner.ZName.Value = found.ZName.Value
            found:Destroy()
        end
        wait (0.01)
    ----[7]----
        local found = descendant.Parent.Parent:FindFirstChild(descendant.Parent.ZName.Value - 1 ..","..descendant.Parent.XName.Value + 1)
        if found then
            local BiomFields = game.Lighting.BiomeFields:GetChildren()
            local ChoosenField = game.Lighting.BiomeFields:FindFirstChild(math.random(1, #BiomFields))
            local FieldCloner = ChoosenField:Clone()
            FieldCloner.Parent = game.Workspace.GeneratedWorld1.Fields
            FieldCloner.Name = (found.ZName.Value..","..found.XName.Value)
            FieldCloner:SetPrimaryPartCFrame(CFrame.new(found.PositionX.Value,found.PositionY.Value,found.PositionZ.Value))
            FieldCloner.PositionX.Value = found.PositionX.Value
            FieldCloner.PositionZ.Value = found.PositionZ.Value
            FieldCloner.PositionY.Value = found.PositionY.Value
            FieldCloner.XName.Value = found.XName.Value
            FieldCloner.ZName.Value = found.ZName.Value
            found:Destroy()
        end
        wait (0.01)
    ----[8]----
        local found = descendant.Parent.Parent:FindFirstChild(descendant.Parent.ZName.Value + 1 ..","..descendant.Parent.XName.Value - 1)
        if found then
            local BiomFields = game.Lighting.BiomeFields:GetChildren()
            local ChoosenField = game.Lighting.BiomeFields:FindFirstChild(math.random(1, #BiomFields))
            local FieldCloner = ChoosenField:Clone()
            FieldCloner.Parent = game.Workspace.GeneratedWorld1.Fields
            FieldCloner.Name = (found.ZName.Value..","..found.XName.Value)
            FieldCloner:SetPrimaryPartCFrame(CFrame.new(found.PositionX.Value,found.PositionY.Value,found.PositionZ.Value))
            FieldCloner.PositionX.Value = found.PositionX.Value
            FieldCloner.PositionZ.Value = found.PositionZ.Value
            FieldCloner.PositionY.Value = found.PositionY.Value
            FieldCloner.XName.Value = found.XName.Value
            FieldCloner.ZName.Value = found.ZName.Value
            found:Destroy()
        end
        wait (0.01)
    ----[9]----
        local found = descendant.Parent.Parent:FindFirstChild(descendant.Parent.ZName.Value - 1 ..","..descendant.Parent.XName.Value - 1)
        if found then
            local BiomFields = game.Lighting.BiomeFields:GetChildren()
            local ChoosenField = game.Lighting.BiomeFields:FindFirstChild(math.random(1, #BiomFields))
            local FieldCloner = ChoosenField:Clone()
            FieldCloner.Parent = game.Workspace.GeneratedWorld1.Fields
            FieldCloner.Name = (found.ZName.Value..","..found.XName.Value)
            FieldCloner:SetPrimaryPartCFrame(CFrame.new(found.PositionX.Value,found.PositionY.Value,found.PositionZ.Value))
            FieldCloner.PositionX.Value = found.PositionX.Value
            FieldCloner.PositionZ.Value = found.PositionZ.Value
            FieldCloner.PositionY.Value = found.PositionY.Value
            FieldCloner.XName.Value = found.XName.Value
            FieldCloner.ZName.Value = found.ZName.Value
            found:Destroy()
        end
        wait (0.01)
        descendant.Parent.BiomIsSpread.Value = true
        descendant.Parent:Destroy()
end
end
end
end
end



0
its talking about line 13 you can just delete it because its just printing workspace mattchew1010 396 — 5y

1 answer

Log in to vote
1
Answered by
Lugical 425 Moderation Voter
5 years ago
Edited 5 years ago

The issue is the name is supposed to be used for instances, not services. Make sure to not print services such as workspace. Lighting shouldn't be used as a storage. ServerStorage should be used for it. I'm afraid I can't paste the script to show as it's too long for an answer. So in other words.

-Make sure to delete line 13, workspace is a service, so it wouldn't work in this situation

-Move all the items you referred from Lighting to ServerStorage. Lighting shouldn't be a storage center

-Make sure to change all the "Lighting" to ServerStorage at the end!

0
I like to think of Lighting as potential alternative storage to uses of ReplicatedStorage as scripts don't run in Lighting. It's probably still heavily frowned upon though however, probably something to do with memory usage. Pejorem 164 — 5y
0
From my understanding, the issue is that Lighting’s service isn’t meant to store instances unrelated to lighting as it could possibly affect them. Lugical 425 — 5y
Ad

Answer this question