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

I'm trying to clone a tree model but I can't figure out how. Please help??

Asked by 3 years ago
Edited 3 years ago

I am making a game for my mother and seeing if she likes it. I need to clone trees because the setting is going to be in the forest.

3 answers

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

If you need to clone a tree, you first need a model, which I think you should have. Then in order to clone the tree using a script, you can do the following.

--Place the model of the tree in ServerStorage
--Then add a script in ServerScriptStorage or Workspace, either of them works.
local ServerStorage = game:GetService("ServerStorage")
local Tree = ServerStorage:WaitForChild("Tree") --I am going to assigning a variable name to your tree, I will be calling it "Tree".

local treeAmount = 10 --Lets spawn 10 trees, you can change it anytime.
local treeSpawned = 0 

while treeSpawned < treeAmount do
    local treeClone = Tree:Clone() --Clone the tree from ServerStorage
    --You would want your trees to be in different positions, so generate a set of numbers.
    local randX = math.random(-50, 50)
    local randZ = math.random(-50, 50)
    --Set position and parent the tree to the workspace.
    treeClone:SetPrimaryPartCFrame(CFrame.new(randX, 0, randZ)) --You can set the tree's position using this method.
    treeClone.Parent = workspace
    treeSpawned = treeSpawned + 1
    wait()
end

0
That seems hard xwainflameskul 16 — 3y
0
What exactly do you want the script to do? Do you want it to clone one tree? If you can provide a bit more detail, maybe I can help more on the problem. ArsonMcFlames 363 — 3y
0
I don't really know how to provide more detail, I just started all this scripting and stuff. I want to spawn them in rows using scripts and from there I can scatter them around the map. xwainflameskul 16 — 3y
0
Also I tried what you showed, I didn't work. xwainflameskul 16 — 3y
0
You're tree is a model right? You also have to set a primary part to your model, to do this, can choose the base of your tree as the primary part. Click you your model, and one of the properties are called "Primary Part", click on it and click on the base of your tree. ArsonMcFlames 363 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Select the tree then press ctrl and d at the same time. Then it will clone the tree

0
I mean in scripts, that would take too long. xwainflameskul 16 — 3y
0
Oh, Then idk. NotANinja_9210 7 — 3y
Log in to vote
0
Answered by 3 years ago

I decided to give up, all I did was duplicate it.

Answer this question