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

How do I make a part 1 stud directly behind the torso?

Asked by 7 years ago

I already know how to make the the part on the direct position of the torso, but I don't know how to make it one stud behind it.

I tried doing this...

(torso.CFrame+Vector3.new(0,0,1))

It works when you're facing a certain direction, but it will go 1 stud in front of you if you go the other direction, and 1 stud to the left if you move sideways. I need a way to make it where it will always be one stud behind the torso, no matter the direction or position.

Any answers/comments will help.

~SkeletalReality

2 answers

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

instead of running;

part.CFrame = (torso.CFrame+Vector3.new(0,0,1))

try running the following:

part.Position = torso.CFrame.LookVector+Vector3.new(0,0,-1)

If it does not work just comment and I'll look into it, this is just the answer I know on the top of my head, so I may be wrong like anybody else. Please accept the answer if it helped!

0
Sorry but that doesn't work, it says "attempt to multiply a Vector3 with an incompatible value type or nil" SkeletalReality 590 — 7y
0
alright let me fix that iamnoamesa 674 — 7y
0
Try now, and tell me what happens if it does not work iamnoamesa 674 — 7y
0
I had to change it to torso.CFrame-torso.CFrame.lookVector since I was multiplying by a CFrame Angle, but nevertheless, it worked! SkeletalReality 590 — 7y
Ad
Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

Hey SkeletalReality,

Nice to meet you, I'm KingLoneCat. What you are asking for is actually quiet simple. All you have to do is set the Part's CFrame equal to the Torso's CFrame multiplied by CFrame.new(0, 0, 1). Below is an example of this.

part.CFrame = torso.CFrame * CFrame.new(0, 0, 1);

It's really quiet that simple. I hope I helped, and have a wonderful day.

~~ KingLoneCat

Answer this question