Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with making this script succesfuly get Players from Players?

Asked by 6 years ago
Edited 6 years ago

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
0
Your making a variable Players and never using it........ great use of RAM. hiimgoodpack 2009 — 6y
0
^It would only take up less than a kilobyte, thats not much at all. PyccknnXakep 1225 — 6y
1
^ Do it about 2000 more times and it becomes a lot... Just because it takes little space, doesn't make it alright to declare without any use... KingLoneCat 2642 — 6y
0
What am I doing wrong? TinyScripter 70 — 6y
0
And also, I DO use player, just read carefully. TinyScripter 70 — 6y

Answer this question