I'm trying to make a projectile of sorts, a part that goes forward and explodes on contact. I want to make it go forward in the direction the origin part is pointed at, and I'm conflicted on how to do that. I think it's got something to do with lookVector, but I'm not too sure. Here's a script I was tinkering around with:
tool = script.Parent part = tool.Handle while true do wait() part.Position = part.CFrame.lookVector * CFrame.new(0, 0, -5).p end
This doesn't work, obviously, because it only goes in a certain direction.
I'd recommend using a BodyVelocity object, but if you absolutely want to do it manually with CFraming then it's as simple as this:
part.CFrame = part.CFrame * CFrame.new(0, 0, -speed)
Here I'm combining two CFrames together; the part's current CFrame and a new CFrame pointing towards negative Z, that is, forward. By combining these two CFrames, I'm effectively translating the first towards the direction described by the second, relative to itself.