Hello, I have a question about this script. It is supposed to get every player from the "Players" thing, but it keeps not working. Here's the error:
18:03:25.623 - Workspace.WinnerServer:9: bad argument #2 to 'random' (interval is empty) 18:03:25.624 - Stack Begin 18:03:25.625 - Script 'Workspace.WinnerServer', Line 9 - global Tree 18:03:25.625 - Script 'Workspace.WinnerServer', Line 22 18:03:25.626 - Stack End
Here is my ServerScript:
math.randomseed(os.time()); local list = {}; function Tree() for index, child in pairs(game.Players:GetChildren()) do wait(); list[index] = child; local Players = game:GetService("Players") end local Player = list[math.random(1,table.getn(list))] local ReplicatedStorage = game:GetService("ReplicatedStorage") local WinEvent = ReplicatedStorage.WinEvent local WinAllEvent = ReplicatedStorage.WinEvent local Character = Player.Character or Player.CharacterAdded:wait() Character.HumaniodRootPart.CFrame = CFrame.new(Vector3.new(1486.811, 12.995, -1925.389)) Player.leaderstats.Wins.Value = Player.leaderstats.Wins.Value + 1 WinEvent:FireClient(Player) local Namez = Player.Name WinAllEvent:FireAllClients(Player.Name) end while true do wait(20) Tree(); end