I am making a game and I need to make it so that it chooses a random player who is in the premises that I specify to go to specific area. How would I do this, I know it involves bool values and stuff but I don't know how to actually teleport a random player. I tried multiple things, including getting players with a letter in their name, like if they have an uppercase A in their name they have a small chance of getting selected. But this wouldn't be fair to people have have uppercase A's in their name. So how would I teleport a random player who has a certain value checked to teleport to coordinates?
✓ ANSWER ACCEPTED
How to randomly select a player to be teleported to a specific area?
1 answer
✓ Accepted answer
You would do this:
local random = math.random(1,#game.Players:GetChildren())
local plr = game.Players:GetChildren()[random]
plr.Character.HumanoidRootPart.Position = Vector3.new(0,0,0) -- teleport the player
I choose a random number which picks the player and then move its head to whatever is in the Vector3
If this worked, accept the answer, thx bye :)
7 comments
0
You should of use CFrame ;)
0
Well
0
This doesn't work as it just brings the head, I tried this with R6 and it didn't work either, I also tried it with torso but it didn't work, It didn't give an error but only brought the body part I chose.
0
wait I meant HumanoidRootPart
0
Ah.
0
It still doesn't work.
0
Then try using CFrame and CFrame.new() or maybe even MoveTo
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
use math.random or random.new
plyr = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())
You would use something like choosingPlr = game.Players:GetPlayers()[math.random(1,#game.Players:Getplayers())]