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

How do you make a random event type script?

Asked by 5 years ago

I'm wanting to make a type of script where every few minutes something random will happen kinda like natural disaster survival, but I'm not sure where to start.. any ideas?

1 answer

Log in to vote
0
Answered by
Vathriel 510 Moderation Voter
5 years ago
Edited 5 years ago

Yeah. First figure out how to code the event. Then make a function that cycles them every few minutes or something using math.random with a loop.

I would program each event as some sort of function or something to make life easy.

--Need to store our event functions
Events = {EventFunction1,EventFunction2} --etc.

--where an event function might look like:

function EventFunction()
    game.Lighting.TimeOfDay = 0
    wait(30)
    game.Lighting.TimeOfDay = 30
end

--need the loop to run everything.

while wait() do
    Events[math.random(1,#Events)]()
end

This code will not work, it's designed to give you the blocks and understanding you need. That's the principle, good luck figuring out the rest.

0
Thanks! larssnakes 24 — 5y
Ad

Answer this question