Could anyone tell me where I went wrong?
1 | function onTouched(part) |
2 | local h = part.Parent:findFirstChild( "Torso" ) |
3 | if (h ~ = nil ) then |
4 | h.CFrame = script.Parent.Parent.Parent.Part 1. Position.CFrame |
5 |
6 | end |
7 | end |
8 |
9 | script.Parent.Touched:connect(onTouched) |
Thetacah you were close, however you have to use CFrame.new, and you tried to CFrame the humanoid instance:
01 | function onTouched(part) |
02 | local h = part.Parent:findFirstChild( "Humanoid" ) |
03 | if h ~ = nil then |
04 | t = h.Parent.Torso |
05 | t.CFrame = CFrame.new(script.Parent.Parent.Parent.Part 1. Position) |
06 | end |
07 | end |
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 |
10 | 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.
I don't use CFrame to often, but I think this should work.
1 | function onTouched(part) |
2 | local h = part.Parent:findFirstChild( "Humanoid" ) |
3 | if h ~ = nil then |
4 | h.CFrame = script.Parent.Parent.Parent.Part 1. Position |
5 |
6 | end |
7 | end |
8 |
9 | script.Parent.Touched:connect(onTouched) |
If you want to move the player to the part do this.
1 | function onTouched(part) |
2 | local h = part.Parent:findFirstChild( "Torso" ) |
3 | if (h ~ = nil ) then |
4 | h.CFrame = CFrame.new(script.Parent.Parent.Parent.Part 1. CFrame.x,script.Parent.Parent.Parent.Part 1. Position.y+ 3 ,script.Parent.Parent.Parent.Part 1. Position.z) |
5 |
6 | end |
7 | end |
8 |
9 | script.Parent.Touched:connect(onTouched) |