Get a position a certain amount of studs in front of a part?

Hey, I just made a post on this but it sent somehow before I was done typing. Don’t know how that happened so I just deleted it.

Anyway, I’m trying to get a position based on the LookVector of another part. I’ve done it in the past using RightVector multiple times and it’s worked, but for some reason it’s not working now. I need a position 12 studs in front of a part. Here’s the script:

	local f = Instance.new("BodyPosition")
	local vector = payloadcontainer.Main.CFrame.LookVector
	f.MaxForce = Vector3.new(0,100000,0)
	f.P = 5000
	f.D = 3000
	f.Position = payloadcontainer.Main.Position + (vector*12)

The main thing is the last line there. To get the position I want, shouldn’t it just be the LookVector times 12? I’ve tried LookVector.Unit but it made no difference. Thanks

1 Like

This would be much simpler with CFrames.

local f = Instance.new("BodyPosition")
f.MaxForce = Vector3.new(0,100000,0)
f.P = 5000
f.D = 3000
local CF = payloadcontainer.Main.CFrame*CFrame.new(0,0,-12) -- gets the CFrame 12 studs infront of the part
f.Position = CF.Position

LookVector is a unit vector, therefore doing LookVector.Unit will return a copy of LookVector.

1 Like

Thanks, that got me the results I was looking for. Still don’t know why my original method didn’t work, I’ve used it in the past and it’s what I’m used to using.