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

Generating Problem [closed]

Asked by 10 years ago

I got an answer from my question on 'Generation' about generating blocks. But is there anyway to fix this? OR understand some of it so ** I ** can fix it? It doesn't connect and stuff you can try it:

local block = script.Parent.Grass
local function GetBlock()
    return block:Clone()
end
local function GetSize()
    return block.Size.z
end
-- Assing random position ranges
local x_min, x_max = -100,100
local z_min, z_max = -100, 100
local y_min, y_max = 1,10 -- this is in block units.
for x = x_min, x_max, GetSize() do 
    for z = z_min, z_max, GetSize() do
        local height = math.random(y_min, y_max)
        for y = GetSize()/2, GetSize() * (height + 0.5), GetSize() do
            local block = GetBlock()
            block.CFrame = CFrame.new(x,y,z)
            block.Parent = game.Workspace
        end
        wait() -- due the amount of recurses; wait, otherwise roblox will crash
    end
end`

Locked by JesseSong

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 10 years ago
Edited by JesseSong 3 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).
local block = GetBlock()
block.CFrame = CFrame.new(x,y,z)
block.Parent = game.Workspace

That will not work because it returns a number. You cannot change a number's CFrame/Parent.

Ad
Log in to vote
-1
Answered by 10 years ago

When answering, if your answer does not fully solve the question, it should be written as a comment to the question instead of as an answer.

what exactly is the problem ?

0
Include a valid description. Simply saying "What exactly is the problem" is not a valid answer, and should be written as a comment INSTEAD of an answer. JesseSong 3916 — 3y