I'm trying to make a leaves falling from the tree.. I really appreciate if you help me,Thank you.
Ok first of all you need to declare some variables:
local tree = game.Workspace.YourTree -- Change the tree's path to your current one local minSec = 0.6 -- The minimum seconds between the last falling and the next one local maxSec = 3 -- The maximum seconds between the last falling and the next one
Ok, what does this means?
tree
this is the instance of your tree model, read the commend for more info :D
minSec
ok so this is a little hard for me to explain, I'm italian that's why, think this:
leaf1 leaf2 leaf3 the leaf1 will fall down from the tree now, a "math.random()" will get a random number between the minSec and the maxSec let's think that the random number is "3" ok? when the leaf1 falls, it waits 3 seconds before the leaf2 will fall.
I hope you understand =)
maxSec
same as over
Ok now that we have the variables we need to make a function that will causes the leaves fall:
function startLeavesFalling() -- Add here your vector3 starting position, I suggest you to start the falling at the top of the tree ;) local startingPosition = {} -- The leaf will be cloned, we suppose that we want infinte leaves ok? local leaf = tree.StockParts.Leaf:Clone() -- We declared a random second between minSec and maxSec for better reality local randomSec = math.random(minSec, maxSec) leaf.Parent = tree -- There will be spawned the leaf =) leaf.Name = "Leaf" -- The leaf will be spawned in a random position from our array of starting positions leaf.Position = startingPosition[math.random(1, #startingPosition)] wait(randomSec) -- We wait the random second before we start another leaf falling event leaf:Destroy() -- We destroy the leaf after another one has spawned, causing no lag =) end
After that we need to call the function, call it wherever you want by using this code:
startLeavesFalling()
I hope you understand :D
Closed as Not Constructive by evaera
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?