Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to teleport a player randomly chosen from script?

Asked by
DogeIXX 172
5 years ago

Hey once again. I am trying to teleport a player using a GameScript. But I dont know how to find the Humanoid from the player.

Script:

local User1 = 5, 5
local User2 = 2, 7
local User3 = 1, 8
local User4 = 10, 18
local User5 = 6, 24
local User6 = 9, 33
local User7 = 7, 40
local User8 = 3, 43
local User9 = 4, 47
local User10 = 8, 55
local CurrentUsers 
local MaximumUsers = 10
NumberOfChildren = #workspace.GameData.Player.InGame:GetChildren()
print(NumberOfChildren)
CurrentUsers = NumberOfChildren

local PlayerFolder = game.Workspace.GameData.Player.InGame:GetChildren()
local rand = Random.new()
local num = rand:NextInteger(1,#PlayerFolder)
local chosen = PlayerFolder[num]

local char = chosen.Character
char.HumanoidRootPart.CFrame = CFrame.new(21.069, 5.3, 38.099) 
0
Use FindFirstChild() to find the humanoid, then put the if statement if it is true or not Yuuwa0519 197 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

its way easier than this all you have to do is refer to the humanoidrootpart if its in a local script you can simply do

game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(21.069, 5.3, 38.099)

if its a server script you need to refer to the player in another way but its still the same thing

Ad

Answer this question