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

How can I make this script a little more dependable and efficient?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Ok, I am making a snow flake script but I want a more efficient way of doing it, this is the current script I am using but it's not the best:

player=game.Players.LocalPlayer
player.Character:WaitForChild("Torso")

flake=Instance.new("Part")
flake.BrickColor=BrickColor.new("Institutional white")
flake.Material=Enum.Material.Wood
flake.FormFactor=Enum.FormFactor.Custom
flake.Shape="Ball"
flake.CanCollide=false
flake.Transparency=0.1
flake.Size=Vector3.new(0.2,0.2,0.2)
vel=Instance.new("BodyVelocity", flake)
vel.Velocity=Vector3.new(0,-5,0)
moo=Instance.new("Model", game.Workspace)
moo.Name=game.Players.LocalPlayer.Name.."snow"

while wait() do
    flakes={}

    for i=1,40 do
        wait(0.15)
        if i > 0 then
            flakes[i]=flake:Clone()
            flakes[i].Parent=moo
            flakes[i].Position=player.Character.Torso.Position+Vector3.new(math.random(-15, 15),15,math.random(-15, 15))
            wait()
            if i-15>0 then
                wait()
                flakes[i-15]:Destroy()
            end
        end
    end
    for i,v in pairs(flakes) do
        wait(0.15)
        v:Destroy()
    end
end

Any recommendations to make this faster and more efficient.

1 answer

Log in to vote
1
Answered by 9 years ago

Turn the "Flake Making" process into a single function called MakeFlake(), or whatever.

Ad

Answer this question