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

Hey i made a map changer but i need help to make it teleport the players when the map loads?

Asked by 8 years ago
Edited by Pyrondon 8 years ago
local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("StatusValue")

while true do
    -- Intermission
    for i = 30, 0, -1 do
        status.Value = "Intermission: " .. i 
        wait(1) 
    end
    local map = game.ServerStorage.GlassMap
    map:Clone().Parent = workspace
    wait(15)
    map:Destroy()
    status.Value = "Game End"
end
--// For future reference, your code has to go in between two sets of tildes(~). You had an extra one messing it up.

I want it to teleport them to the map when the map loads and when the map destroys i want it to teleport them back to the lobby is that possible to fix?

1
Please use code blocks. It is the Lua symbol at the top while editing. Decemus 141 — 8y
0
You could edit the CFrame or position (position is probably better) of all the players in order to teleport them. GoldenPhysics 474 — 8y

1 answer

Log in to vote
0
Answered by
guiraz 25
8 years ago
Edited 8 years ago
players = game:GetService("Players")

 -- loop to get every player in the game
for _, player in pairs(players) do

    local character = player.Character

    --check if the player is not dead
    if character then
        character:SetPrimaryPartCFrame(spawn_part.CFrame) 
        --you must create a variable for the spawn part
    end
end

So it would look like this:

local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("StatusValue")
players = game:GetService("Players")
lobby_spawn = game.Workspace.Spawn --change this to the lobby spawn/part 

while true do
    -- Intermission
    for i = 30, 0, -1 do
        status.Value = "Intermission: " .. i 
        wait(1) 
    end
    local map = game.ServerStorage.GlassMap
    map:Clone().Parent = workspace
    spawn_part = map.Spawn --insert a spawn/part named "Spawn" in the map model

    for _, player in pairs(players) do

        local character = player.Character
        if character then
            character:SetPrimaryPartCFrame(spawn_part.CFrame) 
        end
    end

    wait(15)

    for _, player in pairs(players) do

        local character = player.Character
        if character then
            character:SetPrimaryPartCFrame(lobby_spawn.CFrame) 
        end
    end

    map:Destroy()
    status.Value = "Game End"
end

this will teleport them to the map and then you just have to repeat the loop but using the lobby's spawn. Hope I helped!

Ad

Answer this question