Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to teleport a player without needing a specific part?

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

1 comment

0

Can you be a bit more specific regarding, "I already have the boss defeating part scripted"?

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.