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
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