I am trying to print ONE random players name and excluding my name, I can't get it to work. Any help please?
Error: print(PlayerList[math.random(#PlayerList)]):7: invalid argument #1 to 'random' (interval is empty)
local LocalPlayer = game.Players.LocalPlayer local Players = game.Players:GetPlayers() local PlayerList = {Players} table.remove(PlayerList, table.find(PlayerList, LocalPlayer)) print(PlayerList[math.random(#PlayerList)])
Best thing to do is the following:
RandomPlayer = PlayerList[math.random(1,#Playerlist)]) --[[Now you can exclude your name by randomizing the name repeatedly until the name is NOT yours.]] repeat RandomPlayer = PlayerList[math.random(1,#Playerlist)]) --Getting a new random player. until RandomPlayer ~= --Enter your Username here. print(RandomPlayer)
Also, i havent checked the code. If there are any issues, tell me and well fix them.