Like in a hide and seek game how is that done?
(I'm assuming that you mean teleport as in moving the player around inside a game, not moving them to a different game altogether)
You can teleport players by setting the CFrame
(CoordinateFrame) of their Torso
, like-so:
destinationPart = workspace.TeleportPart --The part that you want to move a player to player.Character.Torso.CFrame = destinationPart.CFrame
As for "at a specific time", you can keep track of time in a loop like this:
timer = 0 --Keeps track of time, in seconds delta = tick() --This loop continually runs in the 'background' of your script timeLoop = coroutine.wrap(function() while wait() do delta = tick() - delta timer = timer + delta delta = tick() end timeLoop() --Now you can check when 'time' reaches a certain value, etc... for example: repeat wait(1) until timer >= 120 --Do something after 2 minutes
Hope that helps!
Not sure exactly what you mean, but I'll do my best.
If you mean teleporting to a specific place in your game, that's easy.
Wherever you need to teleport, just teleport using the MoveTo
using coordinates (Vector3 Value
).
You can find the coordinates (Vector3) by placing a part and looking at its 'Position' property.
If you want to teleport to random spots, that would take a bit more work, you'd have to use a table that takes away each player and Vector3 Value for each player teleported.
However, assuming it's a flat area, the easiest way to teleport "randomly" is to use the math.random
function to teleport randomly.
For example,
x = math.random(0,100) y = 10 -- you can make this a random value as well, but it's not recommended z = math.random(0,100) character = game.Players:findFirstChild("") -- put player here, or if it's undefined, just remove game.Players... etc. and replace it with your character variable; just make sure it's the character, not the player (in Workspace) character:MoveTo(Vector3.new(x, y, z))
math.random takes up to two parameters, the starting value, and the ending value.
math.random(0,100)
...will take a random value from 0 to 100.
math.random(-500,1250)
...will take a random value from -500 to 1250.
Using only one parameter returns a random value from 1 to the parameter provided,
math.random(8)
...returns a random number between 1 and 8
Using math.random() returns a random number, but it's only 0 or 1. Meaning...
math.random()
... returns either 0 or 1.
If you're feeling advanced, you could even try something along the lines of decimals, here's one way to do it, described in the wiki article on math.random I gave you:
math.randomseed(tick()) for _ = 1, 10 do print(math.random()*100) wait(1) end
I hope I helped you, good luck! Please consider upvoting my post!
Here's another link I thought might be helpful to you; it describes all math.x functions you can do, they're quite useful: