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

How do you make a OnTouch Teleport script?

Asked by
iFlusters 355 Moderation Voter
10 years ago

So I want to make a script so when a player touches a brick they get teleported to a certain place, I guess this would be using co-ordinates?

Please reply with a script.

3 answers

Log in to vote
0
Answered by 10 years ago

Here's the most basic one. You can modify it if you have to:

Script inside of a Part:

script.Parent.Touched:connect(function(h)
if game.Players:GetPlayerFromCharacter(h.Parent) then
h.Parent.Torso.CFrame = CFrame.new(0, 1000, 0)  -- Change 0, 1000, 0 to the vectors (co-ordinates) you want
end
end)
Ad
Log in to vote
0
Answered by 10 years ago
partA = game.Workspace.PartA

function onTouch(partA)
    t = partA.Parent:FindFIrstChild("Torso")
    t.CFrame = game.Workspace.PartB.CFrame
end

partA.Touched:connect(onTouch)
Log in to vote
-1
Answered by
Nickoakz 231 Moderation Voter
10 years ago

I'm sorry, Requests are not allowed here. Other than that.

part.Touched:connect(function(p)
    local plr=game.Players:getPlayerFromCharacter(p.Parent)
    if plr~=nil then
        pcall(function()
            plr.Character.Torso.CFrame=Vector3.new(0,0,0)
`       end)
    end 
end)

Answer this question