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

How do you make a part which fall slowly,spinning and also loopable?(Falling in a same spot) [closed]

Asked by 10 years ago

I'm trying to make a leaves falling from the tree.. I really appreciate if you help me,Thank you.

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?

1 answer

Log in to vote
-1
Answered by 10 years ago

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? treethis 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 =)

maxSecsame 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

0
He's actually not requesting a script, he just wants to know what to do to make that. You can just tell him use this and this, instead of giving him a script. :p Slazerick 55 — 10y
0
Then ok, I'm editing the post alessandro112 161 — 10y
0
I edited the post alessandro112 161 — 10y
Ad