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

TP to a brick?

Asked by
DevNetx 250 Moderation Voter
10 years ago

I know how to use co-ordinates to TP, but how to TP to a model without them?

2 answers

Log in to vote
0
Answered by 10 years ago

I use the :MoveTo() function when I teleport players.

I'm not sure how reliable it is, but I like it.

ROBLOX Wiki MoveTo

Ex:

t1=script.Parent

t2=game.Workspace.Tele2--Change this to the name of the part you want the player to be moved to

debounce=false

t1.Touched:connect(function(hit)--Fires if someone touched.

if debounce==false then--Is it cooling down?

debounce=true--No, not cooling down, but it is now.

if hit:FindFirstChild("Humanoid") then -- Checks to make sure it isn't a random brick or anything

hit.Parent:MoveTo(t2.Position,t2)--Moves it to the bricks position

wait(5)--Change this to whatever you want--Cooldown time

debounce=false

end--Ends the if , checking the humanoid

end--Ends the debounce If 
end)--Ends the touched function

I added debounce, so it doesn't mess up anything.

Was off the top of my head. +1 if it helped though.

Ad
Log in to vote
0
Answered by 10 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

I can tell you how to TP to a brick.

tp1 = script.Parent
tp2 = game.Workspace.PartYouWantToTeleportPlayerTo

tp1.Touched:connect(function(hit)
    humanoid = hit.Parent.Humanoid
    if (humanoid ~= nil) then
        torso = humanoid.Parent.Torso
        torso.CFrame = tp2.CFrame
    end
end)
0
The error checking in this doesn't work. 1) Check for `hit.Parent` first. 2) Define humanoid as `hit.Parent:FindFirstChild("Humanoid")` or the check on snippet line 6 is worthless BlueTaslem 18071 — 10y

Answer this question