How do I run/enable a random script or part?
Here is the randomizer script:
folderChildren = game.Lighting.ScriptsNBricks:GetChildren() Current = game.Workspace.CurrentEvent local getCur = Current:GetChildren local picked = math.random(#folderChildren ) while true do wait(5) print(picked) picked.Parent = workspace.Current local script = if picked:IsA("Script") then end if script then script.Disabled = false end wait(5) getCur:Destroy() end
Please Help.
So you're trying to pick a random Instance, but you used math.random incorrectly.
math.random you have to say the 1st number you wan't to randomize for and th last number, see an example:
local randomNumber = math.random(1, 9) print(randomNumber)
Here you just put the table lenght inside the math.random function. If you want to pick an random object from the table, do:
local object = math.random(1, #folderChildren) -- Randomizes a number between the first index of the table and his lenght. local picked = folderChildren[object] -- Gets the picked object --