Script that gives random player a weapon not working

Ok, I made a script which is an example of how this is works (It works i tested it) here is the script:

And I figured out what was wrong. You forgot to see if the amount of players was 0 (when the server first starts)

while wait(1) do
	
	local Players = game.Players:GetPlayers()
	
	if #Players ~= 0 then -- before you didn't check if the amount of players is 0
		local RandomPlayer = Players[math.random(1,#Players)]
		
		print(RandomPlayer)
	end
	
end