How do I make a random player chooser? All I want it to do for now is kill the player. I thought I could do this:
local RP = game.Players:FindFirstChild(Random) RP.Humanoid.Health = 0
But that didn't work. I also tried:
local RP = game.Players:FindFirstChild() RP.Humanoid.Health = 0
and:
local RP = game.Players:FindFirstChild(function() RP.Humanoid.Health = 0
But none of those worked. PLEASE please PLEASE help me!
FYI, I put this script in ServerScriptService.
Perhaps this might work
local Players = game.Players:GetPlayers() local nplrs = #Players local Randomplayer = nil if nplrs > 0 then Randomplayer = Players[math.random(1, nplrs)] end if workspace[RandomPlayer.Name]:FindFirstChild("Humanoid") then workspace[RandomPlayer.Name]:FindFirstChild("Humanoid").Health = 0 end
i know your question is already answered, but i thought for practice i might give it a shot, hope this works
local plrs = game.Players:GetPlayers() local rando = plrs[math.random(1,#plrs)] if rando.Character then if rando.Character:FindFirstChild("Humanoid") then rando.Character.Humanoid.Health = 0 end end print(rando.Name.." was chosen to die")