Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to make touch part teleportation ?

Asked by
PPJASK 19
3 years ago

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

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 COOLGUY16T 37 — 3y

3 answers

Log in to vote
0
Answered by 3 years ago
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!

Ad
Log in to vote
0
Answered by 3 years ago
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.

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
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.

Answer this question