output: 15:11:05.904 - Workspace.Data.Script:10: bad argument #2 to 'random' (interval is empty) 15:11:05.906 - Script 'Workspace.Data.Script', Line 10 15:11:05.907 - Stack End
local data = script.Parent local ready = data.Ready local chosen = data.Chosen local p = ready:GetChildren() while true do wait() if ready.Value >= 2 then wait(5) chosen.Value = p[(math.random(1, #p))].Name else end end
local data = script.Parent local ready = data.Ready local chosen = data.Chosen while true do local p = ready:GetChildren() wait() if ready.Value >= 2 then if #p > 0 then wait(5) chosen.Value = p[(math.random(1, #p))].Name end else end end
The variable p
is only defined once. It will not update itself if the amount of stuff inside of it is changed. I added a check to make sure that it's greater than 0.