I am trying to attach a feature to my roll the dice script that will allow dead players on a certain team to roll for a respawn. As it is for deathrun, I need them to respawn on one of their teammates, not the spawn area.
Trouble is I don’t know how to go about finding an alive player and getting his position to use in a function. I believe what I have to do is create a loop that checks through all players and see if they are alive, but I don’t know how to get the loop to check to make sure the player is a specific team as well and then grab his position.
Currently I have
if chance >= 95 then local guy = POSTION OF FIRST ALIVE TEAMMATE THAT IT FINDS ply:Spawn(); ply:SetPos( guy ); rtdTextToAll(ply:Nick().." rolled a resurrection!"); else rtdClientText(ply,"Your resurrection failed!"); ply:SetNWInt("srtdLastUsed",os.time()); return false end
As you can see, I would put the loop right after the first line, then have variable “guy” be defined as the position of the first alive teammate that the loop finds. So what kind of loop would I make that checks every player that is alive, and on team TEAM_RUNNER, then get this player’s position?