Part generator not generating parts without error?

I’m trying to make a survival game. Right now I’m trying to make a terrain generator (but not Roblox’s one).

So far there are no errors, but nothing is happening, it isn’t cloning the Grass.

local Grass = game.Workspace.Grass

function cloneGrass()
	GrassClone = Grass:Clone()
end

function spawnGrass()
	for count = 1,2 do
	cloneGrass()
	GrassClone.CFrame = Grass.CFrame + Vector3.new(0.5, 0, 0.5)
	end
end

while wait(3) do
	spawnGrass()
end

Change this to:

local cloned = cloneGrass()

Then you refer cloned and change its CFrame, and make sure to specify it’s parent.

The GrassClone must have local behind the word, I did’nt see anything that has this variable.

1 Like

You also need to return the GrassClone from that function, otherwise it would be nil.

2 Likes

Thanks for reminding me.

function cloneGrass()
    local cloned = Grass:Clone()
    return cloned
end
1 Like