Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do I make a meteor shower happen at random times?

I'm making a space game, but I am not very good at scripting. I would like to know how to make a meteor shower happen randomly, because I already have the meteor shower script, which is:

end
local part = Instance.new("Part")
local Explosion = Instance.new("Explosion", Workspace)
local morph = Instance.new("SpecialMesh")
local fire = Instance.new('Fire')
sou2 = Instance.new("Sound", game.Workspace)
sou2.SoundId = "rbxassetid://55224766"
sou2.Parent = game.Players.LocalPlayer.Character
sou2.Volume = 10
 morph.MeshType = "FileMesh"
morph.MeshId = "http://www.roblox.com/asset/?id=1290033"
morph.TextureId = "http://www.roblox.com/asset/?id=1290030"
morph.Scale = Vector3.new(100, 100, 100)
morph.Parent = part
part.Parent = game.Workspace
fire.Parent = part
fire.Size = 100
fire.Heat = 100
part.CanCollide = true
part.CFrame = game.Players.LocalPlayer.Character.Head.CFrame * CFrame.new(0,5000,0)
wait(7)
sou2:play()
local Explosion = Instance.new("Explosion", Workspace)
           Explosion.Position = game.Players.LocalPlayer.Character.Torso.Position
           Explosion.BlastPressure = 100000
           Explosion.DestroyJointRadiusPercent = 0.7
           Explosion.ExplosionType = "CratersAndDebris"
           Explosion.BlastRadius = 200
           Explosion.Hit:connect(function(Part, Distance)
               Part.Anchored = false
               if Distance <= 200 then
                   Part:BreakJoints()
               end
           end)
           --123 

So how can I make it happen randomly and loop that?

2 comments

0

Ahhh!! Make sure to use a Lua Code Block to format your code. You can find it when editing your question.

0

The parent argument to to Instance.new is deprecated.

1 answer

Put all the meteor shower code in a loop:

local minimum = 240 --change to shortest wait time-
local maximum = 600 --change to longest wait time-

while true do
--Insert Meteor Shower Code Here--
	wait(math.random(minimum, maximum))
end

Basically, the meteor shower will run, then wait a random number of seconds between 240 and 600, or whatever you set it to. This is possible with the math.random() function, which takes a random number between two values. It'll do this forever... :P

1 comment

0

Tysm!

This discussion is preserved as it was. New answers, comments, and votes are closed.