This is NOT a request site. Please include any coding you have already done.
Anyways, to get a random player we can just use table[index]. Since the GetPlayers() method returns a table of all the players in the game, this will work. To get the actual random number, we use math.random(), and the # sign to make sure that number is in between 1 and the number of players in the game.
local players = game.Players:GetPlayers()
local randomPlayer = players[math.random(1,#players)]
print(randomPlayer.Name)
To detect when a player dies, we need to use the Died event. To connect this event to all players, we just look through Players with a for loop. Then, since we want to ignore the random player, check if the current player equals the random player, and if it doesn't, connect it to the event.
for i,v in pairs(game.Players:GetPlayers()) do
if v ~= randomPlayer and v.Character then
v.Character.Humanoid.Died:connect(function()
print(v.Name.."died!")
end)
end
end
3 comments
What the? Are you blind? Look at my question it clearly said ANY TIPS and best way to do it. Wow. I didnt ask for coding.
I appriciate the coding youve done but I didnt request it as you said : "This is not a request site".
Read this. You violate points 2, 3, and 4. https://scriptinghelpers.org/help/how-post-good-questions-answers