Answered by
5 years ago Edited 5 years ago
01 | local teleportPlace = Vector 3. new( 0 , 0 , 0 ) |
02 | local text = script.Parent |
03 | local randomplayer = math.random( 1 ,#game.Players:GetPlayers) |
04 | local randomplrHRP = randomplayer:WaitForChild( "HumanoidRootPart" ) |
07 | if text.MouseButton 1 Click then |
09 | print ( "The random player is..." .. randomplayer "!" ) |
10 | print ( "Teleporting" .. randomplayer .. "..." ) |
12 | randomplrHRP.Position = teleportPlace |
13 | print ( "Success teleported" .. randomplayer.. "to the teleportPlace's position!" ) |
15 | error ( "randomplayer was a nil value." ) |
Btw, make the game as R15.
Second, make the teleportPlace's position to the position that you want!
~~ How this script works ~~
We don't need to discuss about what we localed cause its useless to know about though.
1 | if text.MouseButton 1 Click then |
this makes the code that sandwiched inside if text.MouseButton1Click then
fires whenever people click the button.
Btw, if the print code is bugging, just mark them as note or delete them lol... They're useless and do nothing else prints what they did in the output.
Later, if we localed the randomplayer, and then pressed the button, they will sensor about are the randomplayer is in the game, if it doesn't, it put out an error.
In a nutshell, pressed the button, get randomplayer and makes the randomplayer's humanoid root part to the teleportPlace's position!
If you don't know how to make the game to R15, see the below!
And if this helped you, mark this as the answer, if doesn't help or need more explains, comment below down too! thanks :)
Go to my video to see how to make the game r15! Btw subscribe pls