How Do I Teleport Every Player in My Game at Once?

Hello!
I am making a story game and I want all of the players to be teleported to another area simultaneously, however I am not sure how to do it. I have looked for solutions but I can only find answers for how to teleport individual players using teleport pads, which is not ideal for my game. The players start off in an office room and I would like them to be teleported outside to a forest area after my dialogue inside the office has finished. I know where to insert the code into my script to make this happen, but I’m not sure what that code should be.
Thank you!

1 Like
-- Assuming you have a part or trigger in the office room that triggers the teleportation
local teleportPart = game.Workspace.Office.TeleportPart -- Replace "Office" and "TeleportPart" with the actual names of your objects

-- Function to teleport players
local function teleportPlayers()
    local forestLocation = game.Workspace.Forest.TeleportLocation -- Replace "Forest" and "TeleportLocation" with the actual names of your objects

    for _, player in ipairs(game.Players:GetPlayers()) do
        player.Character:MoveTo(forestLocation.Position)
    end
end

-- Connect the teleportation function to the trigger
teleportPart.Touched:Connect(teleportPlayers)

Make sure to replace “Office”, “TeleportPart”, “Forest”, and “TeleportLocation” with the actual names of the objects in your game. This code assumes you have a trigger part named “TeleportPart” in the office room and a teleport location part named “TeleportLocation” in the forest area.

When the teleport part is touched by any player, the teleportPlayers function will be triggered, which will move each player’s character to the position of the teleport location in the forest area.

3 Likes

Thanks! Is there any way to do this without using a teleport pad, like using a different type of trigger that doesn’t require the player to interact with it?

call the function right after the dialogue is finished.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.