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

How do I make a part that teleports you when you step on it?

I have a game that when you go through the door it teleports you to the desired game, any help?

2 answers

✓ Accepted answer

For teleport players to another game you need to use the TeleportService.

Is here in the wiki: TeleportService - Wiki --- TeleportService:Teleport - Wiki

For first, create a ServerScript in your part and put this script:

local place_id = 0 -- Place to teleport

script.Parent.Touched:Connect(function(hit) -- On touch in part
	if hit.Parent:FindFirstChild("Humanoid") then -- Try to find humanoid in hit.Parent / try to find humanoid in player character
		local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) -- or you can use game:GetService("Players"):FindFirstChild(hit.Parent.Name)
		if player then -- If find the player
			game:GetService("TeleportService"):Teleport(place_id,player) -- Teleport player.
		end
	end	
end)

Hope it helped :D

Errors? tell-me on comments.

2 comments

0

Why can't I accept the answer?

0

Because negative reputation.

This is quite a simple task if you are familiar with the games "services". One of these services is the teleporting service. This is what service you have to call to make any request that involves moving a player from place to place.

To accomplish this task add a script to the part you want to teleport the player with. The script should look like this:

local placeId = -- id of the place you want to teleport them to

local TeleportService = game:GetService("TeleportService") -- getting the teleport service
script.Parent.Touched:Connect(function(hit) -- this fires every time the object is touched
	local h = hit.Parent:FindFirstChild("Humanoid") -- making sure a player touched it
	if h then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- getting the player
		TeleportService:Teleport(placeId, player) -- teleporting the player
	end
end)

Hope I helped

-Cmgtotalyawesome

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