Im making a door that will give you a random hat and it will randomly enable one of the ten hat giver scripts but i dont know how to do that! please help!
local script1 = script.Parent.Script1 local script2 = script.Parent.Script2 local script2 = script.Parent.Script3 local script4 = script.Parent.Script4 local script5 = script.Parent.Script5 local script6 = script.Parent.Script6 local script7 = script.Parent.Script7 local script8 = script.Parent.Script8 local script9 = script.Parent.Script9 local script10 = script.Parent.Script10 while true do print "Help Me!!!!" end
First off, put all the scripts in a table, like this:
local ScriptTable = { script.Parent.Script1; script.Parent.Script2; script.Parent.Script3; script.Parent.Script4; script.Parent.Script5; script.Parent.Script6; script.Parent.Script7; script.Parent.Script8; script.Parent.Script9; script.Parent.Script10 }
Then you would select a random element from that table, like this:
local RandomScript = ScriptTable[math.random(1,#ScriptTable)]
Finally you would enable that chosen script, like this:
RandomScript.Disabled = false
Together it should look like this:
local ScriptTable = { script.Parent.Script1; script.Parent.Script2; script.Parent.Script3; script.Parent.Script4; script.Parent.Script5; script.Parent.Script6; script.Parent.Script7; script.Parent.Script8; script.Parent.Script9; script.Parent.Script10 } local RandomScript = ScriptTable[math.random(1,#ScriptTable)] RandomScript.Disabled = false
Hope this helped!