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

How would I make all players teleport rather than just one?

Asked by
7Woofy 0
2 years ago

So in the game the script teleports the players into the arena, this is a script inside serverscriptservice and it only teleports on player when the Inround function is called. How do I make it so it teleports all players?

-- Variables
local roundLength = 120 -- time in round
local intermissionLength = 15 -- time between
local waitLength = 10 -- time for grabbing weapons
local InRound = game.ReplicatedStorage.InRound -- whether in the game
local Status = game.ReplicatedStorage.Status -- status of this

InRound.Changed:Connect(function()
    wait(1)
    if InRound.Value == true then
        for _, player in pairs(game.Players:GetChildren()) do
            local char = player.Character
            char.HumanoidRootPart.CFrame =                  game.Workspace.GameAreaSpawn.CFrame
            wait(9)
            local rn = math.random(1,4) -- teleports to a spot on the map
            if rn == 1 then
                player.Character.HumanoidRootPart.CFrame =  CFrame.new(-84.943, 70.289, -457.808)
                print(rn)
            elseif rn == 2 then
                player.Character.HumanoidRootPart.CFrame =  CFrame.new(-113.94, 71.179, -511.147)
                print(rn)
            elseif rn == 3 then
                player.Character.HumanoidRootPart.CFrame =  CFrame.new(-27.698, 74.652, -545.372)
                print(rn)
            elseif rn == 4 then
                player.Character.HumanoidRootPart.CFrame =  CFrame.new(-67.733, 69.304, -568.974)
                print(rn)
            end
        end
    end
end)


local function roundTimer() -- gui at the top of the screen
    while wait() do
        for i = intermissionLength, 1, -1 do
            InRound.Value = false
            wait(1)
            Status.Value = "Intermission: ".. i .." seconds left.."
        end
        for i = waitLength, 1, -1 do
            wait(1)
            Status.Value = "You have ".. i .." seconds, choose your weapons wisely.."
            InRound.Value = true
        end

        for i = roundLength, 1, -1 do
            wait(1)
            Status.Value = "Game:".. i .." seconds left.."
        end
    end
end

spawn(roundTimer)
0
Oh wait nevermind, I figured it out. Instead of (game.Players:GetChildren()) I should put (game.Players:GetPlayers()). My bad. 7Woofy 0 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
-- Variables
local roundLength = 120 -- time in round
local intermissionLength = 15 -- time between
local waitLength = 10 -- time for grabbing weapons
local InRound = game.ReplicatedStorage.InRound -- whether in the game
local Status = game.ReplicatedStorage.Status -- status of this

do local Players,tp,tab=game:GetService"Players",function(p,cf)
        p.Character:SetPrimaryPartCFrame(cf)
end,
{CFrame.new(-84.943,70.289,-457.808),
    CFrame.new(-113.94,71.179,-511.147),
    CFrame.new(-27.698,74.652,-545.372),
    CFrame.new(-67.733, 69.304, -568.974)
}InRound.Changed:Connect(function()
        for _,player in ipairs(InRound.Value and wait(waitLength)and Players:GetPlayers())do
        pcall(tp,player,tab[math.random(1,#tab)])
    end
    end)end;
while true do
    InRound.Value = false
    for i = intermissionLength, 1, -1 do
        Status.Value = "Intermission: ".. i .." seconds left.."
        wait(1)
    end
    InRound.Value = true
    for i = waitLength, 1, -1 do
        Status.Value = "You have ".. i .." seconds, choose your weapons wisely.."
        wait(1)
    end
    for i = roundLength, 1, -1 do
        Status.Value = "Game:".. i .." seconds left.."
        wait(1)
    end
end
Ad

Answer this question