Touch one part to teleport all players and Yourself to another part

Hello! I need some help for teleporting players.
I wanted to create: Touch one part to teleport all players and Yourself to another part.
Thank you to anyone who helps me.

local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")

local goalPart = Workspace:WaitForChild("GoalPart")

part.Touched:Connect(function(hitPart) -- Listen for when the part is touched and call this function
    for _, player in Players:GetPlayers() do -- Loop through all the players in the game
        -- If this particular player's character exists, then teleport them
        -- We should teleport them above, and not directly inside the part
        if not player.Character or not player.Character:FindFirstChild("HumanoidRootPart") then
            continue
        end
        player.Character.HumanoidRootPart.CFrame = goalPart.CFrame + (Vector3.yAxis * 3)
    end
end)
1 Like

the parts where I touch to be teleported, What name should I put?

Thanks, I solved the name problem.

You can name it anything, just make sure to reference it accordingly in the script.

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