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

Teleport to part, not position.

Asked by 11 years ago

Could anyone tell me where I went wrong?

1function onTouched(part)
2 local h = part.Parent:findFirstChild("Torso")
3 if (h ~=nil) then
4h.CFrame = script.Parent.Parent.Parent.Part1.Position.CFrame
5 
6 end
7 end
8 
9script.Parent.Touched:connect(onTouched)

3 answers

Log in to vote
0
Answered by 11 years ago

Thetacah you were close, however you have to use CFrame.new, and you tried to CFrame the humanoid instance:

01function onTouched(part)
02local h = part.Parent:findFirstChild("Humanoid")
03if h ~= nil then
04t = h.Parent.Torso
05t.CFrame = CFrame.new(script.Parent.Parent.Parent.Part1.Position)
06end
07end
08--Keep in mind that the player will go inside of that part, but if you want to get the player on top of it you can PM my ROBLOX
09 
10script.Parent.Touched:connect(onTouched)

Where you went wrong was you put Position.CFrame, where the only sub-properties of Position are X, Y, and Z.

0
I raised the part over the ground so that the player is not stuck in the ground. Thank you. ConnorVIII 448 — 11y
Ad
Log in to vote
1
Answered by
Thetacah 712 Moderation Voter
11 years ago

I don't use CFrame to often, but I think this should work.

1function onTouched(part)
2 local h = part.Parent:findFirstChild("Humanoid")
3 if h ~=nil then
4h.CFrame = script.Parent.Parent.Parent.Part1.Position
5 
6 end
7 end
8 
9script.Parent.Touched:connect(onTouched)
Log in to vote
1
Answered by
Teeter11 281 Moderation Voter
11 years ago

If you want to move the player to the part do this.

1function onTouched(part)
2 local h = part.Parent:findFirstChild("Torso")
3 if (h ~=nil) then
4h.CFrame =CFrame.new(script.Parent.Parent.Parent.Part1.CFrame.x,script.Parent.Parent.Parent.Part1.Position.y+3,script.Parent.Parent.Parent.Part1.Position.z)
5 
6 end
7 end
8 
9script.Parent.Touched:connect(onTouched)

Answer this question