I'm making a script that chooses a random Player and makes them DJ, But It won't work! Can someone please help?
I changed it up some more and uses someones solution, But I still get the same result! (Ignore the headphones part,)
local Headphones = game.ServerStorage["DJHeadphones"]
local Set = game.Workspace["DJ Set"]
local DJName = Set.CurrentDJ
local Teleport = Set.Teleport
local Players = game.Players:GetPlayers()
DJName.Value = "Choosing New DJ"
while wait(15) do
local DJHeadphones = Headphones:Clone()
local DJ = Players[math.random(1,#Players)]
DJName.Value = DJ.Name
DJ:MoveTo(Teleport.Position + 0,3,0)
DJHeadphones.Parent = DJ.Character
DJHeadphones.Handle.CFrame = CFrame.new(DJ.Character.Head.Position)
wait(160)
DJHeadphones:Destroy()
DJ:MoveTo(game.Workspace.DanceFloor.Teleport.Position + 0,3,0)
DJName.Value = "Choosing New DJ"
end
Here's the Output. (Still stayed the same! Other than the dates.)
13:18:14.384 - ServerScriptService.DJChooser:11: bad argument #2 to 'random' (interval is empty) 13:18:14.386 - Script 'ServerScriptService.DJChooser', Line 11

1 comment
The problem wasn't with indexing (although it was faulty), but finding a number within the provided range because the first argument was greater than the second (1 > #Players)