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

How can i make players teleport in a specific area?

Asked by 8 years ago

if i want the players to move to a different area, what do i do?

1
Wrong concept. The teleportation service teleports player's across different places/games. Not some where else in the same place. LateralLace 297 — 8y

2 answers

Log in to vote
-2
Answered by 8 years ago
wait(5)
for i, v in   pairs(game.Players:GetChildren()) do  v.Character.Torso.CFrame = CFrame.new(Vector3.new(50, 50, 50)) -- Change these coordinates to where you want the players to be teleported to
end


Ad
Log in to vote
-1
Answered by 8 years ago

^^^Above answer only works once (since the player's character changes every time he/she dies)^^^

A solution to this is to grab that player's character everytime it respawns:

game.Players.PlayerAdded:connect(function(player) --grabs that specific player
    player.CharacterAdded:connect(function(character)
        repeat wait() until character.Torso.CFrame ~= nil -- to make sure that the torso exists
        character.Torso.CFrame = CFrame.new(workspace.Spawn.Position) + Vector3.new(0,10,0) --          set's the player's RESPAWN location
        repeat wait() until --will wait() until desired teleportation is called
        character.Torso.CFrame = CFrame.new(--Put desired position here<--)
         character.Humanoid.Died:connect(function()
            wait(2)
            player:LoadCharacter() --actually respawns the player once he/she has died
        end
    end
end

Now if your wanting to teleport a player within a certain area (but not in an exact location), you'd use add this piece of code onto the one above:

character.Torso.CFrame = CFrame.new(math.random(min,max),math.random(min,max),math.random(min,max))

--Replace "MIN" and "MAX" with the minimum and maximum X,Y,Z coords

Answer this question