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

How to teleport a player on brick touch? [closed]

Asked by 10 years ago

I have a large brick. I would like a player to teleport to a certain area on humanoid touch, but not sure how to script it.

Locked by youtubemasterWOW, zblox164, and JesseSong

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

4 answers

Log in to vote
5
Answered by 10 years ago

Put this script in the block being touched.

place = CFrame.new(0,0,0) -- Where you want the player to go on touched
script.Parent.Touched:connect(function(p)--Creating the function
local humanoid = p.Parent:findFirstChild("Humanoid")--Trying to find the humanoid
if (humanoid ~= nil) then -- Checking if what touched it IS a player.
humanoid.Torso.CFrame = place -- Moves the torso to what is specified in the place variable
end
end)--Ending the fuction, if you see on the function line above there is an unclosed parenthesis that I am closing here.

If this does not work, reply with the error please so I can fix it, because I sometimes make silly errors

0
there is an error, there is no Torso inside of the Humanoid :) thehybrid576 294 — 6y
0
You are probably using R15, change it to LowerTorso. JarFullOfMayonnaise 48 — 6y
0
No way. I just posted the same code. I didn't know that this was here! lol GodsGraceSavesAll 6 — 6y
0
Use HumanoidRootPart instead of Torso despicablejack2005 83 — 5y
Ad
Log in to vote
3
Answered by 10 years ago

You use the Touched event and the MoveTo method.

Brick = script.Parent -- 1
AnotherBrick = game.Workspace.AnotherBrick -- 2

Brick.Touched:connect(function(part) -- 3
    if part.Parent.Humanoid then -- *
        if part.Parent.Humanoid.Health > 0 then -- 4
            part.Parent:MoveTo(AnotherBrick.Position) -- 5
        end
    end
end)

-- 1 The teleportation brick
-- 2 The destination of the teleportation brick
-- 3 When the teleportation brick is touched, (part) is the part the touched it.
-- 4 If it was touched by a part within a character model, and the character is alive,
-- 5 Move the character model to the destination.

--* Suggesting that the part that touched the teleportation brick is a leg or something. If the teleportation brick is as tall as a Character, then you might have to script something else in case the Character's Hat touched the brick instead.
Log in to vote
0
Answered by 6 years ago

This works for me just be careful I used this with R6 it may not work with R15 or Rthro.

place = CFrame.new(-61.64, 11.365, 1.225) -- Where you want the player to go on touched
script.Parent.Touched:connect(function(p)--Creating the function
local humanoid = p.Parent:findFirstChild("Humanoid")--Trying to find the humanoid
if (humanoid ~= nil) then -- Checking if what touched it IS a player.
humanoid.Torso.CFrame = place -- Moves the torso to what is specified in the place variable
end
end)--Ending the fuction, if you see on the function line above there is an unclosed parenthesis that I am closing here.
0
It worked for me, but only on roblox studio. It doesn`t want to work in game dirtykl_l 0 — 6y
0
Hmmm GodsGraceSavesAll 6 — 5y
Log in to vote
0
Answered by 4 years ago
local teleportpart = script.Parent -- The part you want to teleport the player
teleportpart.Touched:Connect(function(hit)
    if hit.Parent.HumaniodRootPart then
        hit.Parent.HumanoidRootPart.Position = Vector3.new(0,0,0) -- What ever X,Y,Z you want
    end
end)