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

Any help w/ getting teleported to a part?

This script is inside a part. When you touch it, it will bring you to those cords in the script. But it takes everyone in the game w/ you to the part at the cords.

function lol()
	local player = game.Players:GetPlayers()
for i = 1, #player do
	player[i].Character:MoveTo(Vector3.new(12.4, 10.649, -209.491)) --Change the cords to what you want to teleport to!  "(12.12.12))"
end
end

script.Parent.Touched:connect(lol)

If you could help me, THANK YOU VERY MUCH!

2 answers

✓ Accepted answer
function onTouch(hit) 
local human = hit.Parent:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(human.Parent)
	if human then
	player.Character:MoveTo(Vector3.new(12.4, 10.649, -209.491)) 
	end
end

script.Parent.Touched:connect(onTouch)

--you can even cut some of the code since you could just move the humanoid parent...

2 comments

0

Thanks a lot!

0

EDIT YOUR CODE. PUT THE PLAYER LINE [line 3] INSIDE THE CONDITIONAL

I have Never used the MoveTo Method I use CFrame.

script.Parent.Touched:connect(function(hit)
	if hit.Parent then
		local hum = hit.Parent:findFirstChild("Humanoid")
		if hum then
			local torso = hit.Parent:findFirstChild("Torso")
			if torso then
				torso.CFrame = CFrame.new(12.4, 10.649, -209.491)
			end
		end
	end
end)

This is tested and works.

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