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

How to teleport a player without needing a specific part?

Asked by
Synkthh -3
2 years ago
Edited 2 years ago

I have this script that when touching a part; you'll be teleported to a different game. This all works fine and dandy although I want to inverse it instead of touching a part after they defeat a boss, they'll be brought back to the main world. I cannot seem to figure out how to make it so they'll be teleported without having to touch a specific part. (I already have the boss defeating part scripted and that's all fine I just need the part where they teleport back for just being there)

wait(20)
    local teleportservice = game:GetService("TeleportService")

    local gameid = 6873694107 

    local function onparttouch(otherPart)
        local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
        if player then
                teleportservice:Teleport(gameid, player)
            end
        end
    end
0
Can you be a bit more specific regarding, "I already have the boss defeating part scripted"? Hieroglyphica 0 — 2y

1 answer

Log in to vote
0
Answered by
Synkthh -3
2 years ago
Boss.Humanoid.Died:Connect(function()
local TeleportService = game:GetService("TeleportService") 
local gameid = gameid 

  local playerArray = Players:GetPlayers()
  for i=1,#playerArray do
    teleportservice:Teleport(gameid, playerArray[i])
  end
end

After asking a friend this is what they gave me and it works; thanks to anyone who commented

Ad

Answer this question