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

How to rotate LookVector value?

Asked by
WoTrox 345 Moderation Voter
4 years ago
Edited 4 years ago

I'm trying to make a pistol, but I'm stuck at this part. The char.CharPistol.Shoot is the pistol's barrel inside the character.

bullet.Velocity = (char.CharPistol.Shoot.CFrame.LookVector * Vector3.new(1, 1, 1)) * 10

The bullet flies left

bullet.Velocity = (char.CharPistol.Shoot.CFrame.LookVector * Vector3.new(-1, 1, -1)) * 10

The bullet flies right. If the two values on the side are not equal, the bullet flies weirdly, but not forward. How can I make the bullet fly straight forward?

1 answer

Log in to vote
1
Answered by 4 years ago

try using vector3.Unit

local gun =  workspace.Part
local aim =  workspace.Part2

bullet.Velocity = (gun.Position-aim.Position).Unit * Speed

Place the aim part in front of the gun part and weld them

(sorry for my bad english)

0
Thank you! WoTrox 345 — 4y
Ad

Answer this question