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 10 years ago

Could anyone tell me where I went wrong?

function onTouched(part)
 local h = part.Parent:findFirstChild("Torso")
 if (h ~=nil) then
h.CFrame = script.Parent.Parent.Parent.Part1.Position.CFrame

 end
 end

script.Parent.Touched:connect(onTouched)

3 answers

Log in to vote
0
Answered by 10 years ago

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

function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h ~= nil then
t = h.Parent.Torso
t.CFrame = CFrame.new(script.Parent.Parent.Parent.Part1.Position)
end
end
--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

script.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 — 10y
Ad
Log in to vote
1
Answered by
Thetacah 712 Moderation Voter
10 years ago

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


function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h ~=nil then h.CFrame = script.Parent.Parent.Parent.Part1.Position end end script.Parent.Touched:connect(onTouched)
Log in to vote
1
Answered by
Teeter11 281 Moderation Voter
10 years ago

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


function onTouched(part) local h = part.Parent:findFirstChild("Torso") if (h ~=nil) then h.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) end end script.Parent.Touched:connect(onTouched)

Answer this question