In my game i want a feature that a random player teleports to a part. I really need this in my game but i have no clue how to do it. Also i want it that it showes in the top of the screen. Like a timer that shows how long time itscleft befors the game begins or ends. Please someone help me.
COMMUNITY QUESTION
How do you teleport random player to a specific location?
2 answers
not too good at this but here you go
local part = workspace:FindFirstChild("the specific part you want the player to teleport to")
function tele()
local players = {}
for i,v in pairs(game.Players:GetPlayers())do
table.insert(players,v)
end
local chosenPlayer = players[math.random(1,#players)]
chosenPlayer.Character.HumanoidRootPart.Position = part.Position + Vector3.new(0,3,0)
end
tele() -- call this function when you want to teleport
Here's a way to teleport the player and it has a timer
local time = 0
local plrs = game.Players:GetChildren()
local plr = math.Random(1,#plrs)
for p = 1,#plrs do
plrs[p].Character.Torso.CFrame = CFrame.new(0,0,0)----- The spot you want the player to appear at
time = 120
wait(2)
repeat
time = time - 1
wait(1)
until time == 0
This discussion is preserved as it was. New answers, comments, and votes are closed.
