I'm trying to make scripts execute in random order, kinda like horrific housing, sorry if this is a request it was my last choice.
✓ ANSWER ACCEPTED
How do you make scripts execute in random order?
2 answers
✓ Accepted answer
a way you could do this is by having one central script, with a math.random function. like this:
while wait(10) do -- any number works
local number = math.random(1,10)
if number == 1 then
print("doing things")
elseif number == 2 then
print("doing more things")
--and so on
end
Use a ModuleScript. You can read more about them here.
Basically, make one parented to your regular script. then do something like:
local modes = {}
function modes:Mode1()
--Code for mode 1
end)
function modes:Mode2()
--Code for mode 2
end)
function modes:Mode3()
--Code for mode 3
end)
--Repeat
return modes
Then, in your regular server, do something along the lines of:
local modeModule = require(script:WaitForChild("The name of your module script here"))
while true do
mode = math.random(1, the number of modes you have)
if mode == 1 then
modeModule:Mode1()
elseif mode == 2 then
modeModule:Mode2()
elseif mode == 3 then
modeModule:Mode3()
end
end
Hope this helps. Also I didn't test this, reply with errors!
This discussion is preserved as it was. New answers, comments, and votes are closed.
