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

How do I make an erupting volcano?

Asked by 8 years ago

Ok, so I just started Lua last week and have been working hard. I want to slowly teach myself some basics with help from the Wiki and Youtube videos. I have tried to make lots of bricks come out of one place but they wont go away. I tried to make them go away but I can't.

Here is my code:

local f = game.ServerStorage.Fire

bool = true

while bool do
    local fCopy = f:Clone()
    fCopy.Parent = game.Workspace
    wait(0)
end

wait(1)
f:Destroy()

Btw the fire from the volcano is in the Server Storage

2 answers

Log in to vote
0
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

You could add the objects to Debris so it doesn't yield.

local f = game.ServerStorage.Fire
firing = true

while firing do
    local fCopy = f:Clone()
    fCopy.Parent = game.Workspace
    game:GetService('Debris'):AddItem(fCopy, math.random(1, 10))
end

What this does is destroy the object within one and ten seconds. You could replace this with a static number, if you choose:

game:GetService('Debris'):AddItem(fCopy, 5)

You may want to find a more efficient way to do this, though; as thehybrid576 said, no other code after the while loop will run in the script until you break the loop.

Hope this helped.

Ad
Log in to vote
0
Answered by 8 years ago
local serverstorage = game:GetService("ServerStorage")
local f =serverstorage.Fire

bool = true

while bool do
    local fCopy = f:Clone()
    fCopy.Parent = game.Workspace
    wait(1)
    fCopy:Destroy() --You are destroying fCopy, since it is the object in the Workspace, also this has to be inside the while true do loop because no other script after this can run until you break the loop
end



0
This does not quite work... Now with that wait, I am having to wait for the block to clone. daphnie252 35 — 8y

Answer this question