Error message I receive: Workspace.WorldGenerator:6: (also lines 7-9) attempt to index field 'Bedrock' (a function value)
Here's the code albeit a bit inefficient. but you get the idea.
I'm attempting to create all my block data inside of a module script which I can retrieve from other scripts (such as my terrain generator) simply for having it all in a nice convenient layout.
On a side note, I know that returning a value makes it 'read-only' but I can't really think of how else I could make this happen.
-- Server script
local Blocks = require(game:GetService("ServerScriptService"):WaitForChild("Modules"):WaitForChild("BlockStatistics"))
local worldwidth = 50
local worldheight = 8
function PrepareGrid()
print(Blocks.Bedrock.Name)
-- Blocks.Bedrock.Position = Vector3.new(-(worldwidth/2),-worldheight, -(worldwidth/2)) --laying bottom layer for Bedrock
-- Blocks.Stone.Position = Blocks.Bedrock.Position
-- Blocks.Dirt.Position = Blocks.Bedrock.Position
( I decided to leave only the relevant parts of the script which is tossing the error codes)
-- Module Script
local Blocks = {}
local BlockSize = Vector3.new(3,3,3) --Size of blocks in-game.
local BlockShape = "Block"
Blocks.Air = function()
local ItemID = 0 -- this is an attempt to support commands for spawning in items
local Size = BlockSize
local Shape = BlockShape
end
Blocks.Stone = function()
local ItemID = 1
local Size = BlockSize
local Shape = BlockShape
local Stone = game:GetService("ServerStorage"):WaitForChild("Blocks"):WaitForChild("Terrain"):WaitForChild("Stone")
return Stone
end
Blocks.Dirt = function()
local ItemID = 3
local Size = BlockSize
local Shape = BlockShape
local Dirt = game:GetService("ServerStorage"):WaitForChild("Blocks"):WaitForChild("Terrain"):WaitForChild("Dirt")
return Dirt
end
Blocks.Bedrock = function()
local ItemID = 7
local Size = BlockSize
local Shape = BlockShape
local Bedrock = game:GetService("ServerStorage"):WaitForChild("Blocks"):WaitForChild("Terrain"):WaitForChild("Bedrock")
return Bedrock
end
return Blocks

1 comment
Could you go into a little more detail on what you mean by You can change all of those to
Block.BlockName = BlockType?