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

Problem with the creation of the world why?

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



1 comment

0

its talking about line 13 you can just delete it because its just printing workspace

1 answer

✓ Accepted answer

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!

2 comments

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.

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.

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