greipster
(human)
August 23, 2021, 11:54am
#1
I am working on a randomized tree generator. Can anyone help me, by explaining to me, why this isn’t working. No objects are appearing in the “Trees” folder.
local tree = game:GetService("ReplicatedStorage").Tree
for i = 0, 15 do
local clone = tree:Clone()
clone.Position = Vector3.new(math.random(-200, 200), 500, math.random(-200, 200))
clone.Parent = workspace.Trees
end
Can you show your output for me?
1 Like
greipster
(human)
August 23, 2021, 12:00pm
#3
As clear as a glass of water. No errors or anything.
1 Like
soccervr
(soccervr)
August 23, 2021, 12:02pm
#4
Maybe you should change the zero to a one.
1 Like
Did you attempt doing print checks? Also could you try for I = 1,15 instead of 0
1 Like
greipster
(human)
August 23, 2021, 12:04pm
#6
I did run the loop with print checks, and guess what? It is not the loop.
The problem lies somewhere in the cloning maybe?
Is this on the server or client?
1 Like
Oh i think I see the issue, try doing local tree = game.ReplicatedStorage.Tree:Clone()
1 Like
greipster
(human)
August 23, 2021, 12:05pm
#9
server script, the code shown above is the whole script
Also that wouldn’t matter since the object is in ReplicatedStorage so it’s accessible by both
1 Like
Also just do tree instead of making a new clone variable
1 Like
greipster
(human)
August 23, 2021, 12:06pm
#12
By doing that, wouldn’t I only clone it once?
And, no, it would matter, I intend to do the spawning on the server
No, it wouldn’t clone it once since in the for loop it will call it 15 times
3 Likes
greipster
(human)
August 23, 2021, 12:11pm
#14
Hold up, the client can’t see the trees, but the server can.
How?
Server
Client
I just tested this out and it works perfectly fine for me, The issue might be in another script maybe?
1 Like
Is the tree anchored? I had an issue when I first started our where if it wasn’t anchored it’d fall under the map and disappear
1 Like
greipster
(human)
August 23, 2021, 12:22pm
#17
These are the properties for the test part:
greipster
(human)
August 23, 2021, 12:26pm
#18
Ahaa. I think I just figured it out.
Does StreamingEnabled not let parts appear?
1 Like
At certain distances I believe so, maybe that’s the issue
1 Like
greipster
(human)
August 23, 2021, 12:33pm
#20
Yes. I just moved closer to the trees, and boom. They all spawned!
1 Like