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.
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
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.
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.
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)
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?