Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to teleport a player randomly chosen from script?

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) 

1 comment

0

Use FindFirstChild() to find the humanoid, then put the if statement if it is true or not

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.