You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
Hi, I’m developing a gnarly (cool even) world generation that generates pillars on based on a vector position, with varying heights ecte ct. Basically it’s pillars being generated out of 2 pillars which are
a pillar
and a not pillar (a pillar but with nocollide and transparent)
This is my code so far!
local Plates = game.ReplicatedStorage.Places:GetChildren()
local x = -25
local z = -25
local PlatePos = {}
for count = 1,50 do
for count2 = 1,50 do
local PlateSpawn = Plates[math.random(1,#Plates)]:Clone()
PlateSpawn.Primary.Position = Vector3.new(x * 200, math.random(-50,50), z * 200)
PlateSpawn.Parent = game.Workspace.Plates
PlatePos[Vector2.new(x, z)] = PlateSpawn
x += 1
end
x = -25
z += 1
end
x = -25
y = -25
print(PlatePos)
for count = 1,50 do
for count2 = 1,50 do
local BasePlate = PlatePos[Vector2.new(x,y)]
if BasePlate.bridge == true then
BasePlate.bridgegenerated = true
local BridgingPlate = PlatePos[Vector2.new(x - 1, y)]
if BridgingPlate.bridge == true and BridgingPlate.bridgegenerated == false then
local BridgePart = game.ReplicatedStorage.BridgePart:Clone()
BridgePart.Size = Vector3.new((BridgingPlate - BasePlate).Magnitude, 24, 150)
BridgePart.CFrame = Vector3.new(BasePlate.Primary.Position, BridgingPlate.Primary.Position)
BridgePart.Parent = game.Workspace
end
end
x += 1
end
x = -25
z += 1
end
-
What is the issue?
I am getting an error! This is the error:
ServerScriptService.Scripts.Generate:27: attempt to index nil with 'bridge'
I’m pretty new to dictionaries though, I almost expected it to go wrong - I’m just not sure how to fix it.
-
What solutions have you tried so far?
I have a pretty good coding friend who also couldn’t find out what was going on. I know that somehow BasePlate is nil, I just dont understand how.