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

how to make touch part teleportation ?

How to make if player team red and he touch part1 then teleport to part2

part1 = script.Parent.Part1 part2 = script.Parent.Part2

thank u and best regards -PPJASK

1 comment

0

Next time you ask a question, please attempt what you are asking first and if it errors and you dont know how to fix it THEN come here and put the code that errored in your question

3 answers

function onTouch(part)
if part.Parent.Humanoid ~=nil then
part.Parent:MoveTo(location where you want to teleport)
script.Parent.Parent.Tele2.Script.Disabled = true 
wait(2)
script.Parent.Parent.Tele2.Script.Disabled = false
end
end
script.Parent.Touched:connect(onTouch)

Put this script on both parts!

local Part1 = script.Parent.Part1
local Part2 = script.Parent.Part2

Part1.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("HumanoidRootPart") then
		hit.Parent.HumanoidRootPart.CFrame = Part2.CFrame
		end
	end
end)

The script basically just teleports you to the second part.

local Part1 = script.Parent.Part1 
local Part2 = script.Parent.Part2

Part1.Touched:Connect(function(hit) --This starts the function when part got touched by something
local hmr = hit:FindFirstChild("HumanoidRootPart") --Setting Humanoid Root Part Variable
 if hmr ~= nil then --Checking if Humanoid Root Part exists
  hmr.CFrame = CFrame.new(Part2.Position) --Teleporting player character CFrame to part2 CFrame
 end --Ending the "if" statement
end) --Ending the function

There you go.

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