Script
Bullet.CFrame = CFrame.new(gunPos, MousePos) Bullet.Orientation = Vector3.new(Ori) Bullet.Velocity = char.HumanoidRootPart.CFrame.lookVector * Speed
Variables
gunPos = Gun.Handle.Position
MousePos = Mouse.Hit.p
Ori = Gun.Parent.HumanoidRootPart.CFrame.lookVector
Problem
I don't understand, the bullet of my gun doesn't go where my mouse is but it goes straight. And it doesn't rotate, it stays at it's default orientation.
What am i doing wrong here? Should i use something else for the mouse? ( Like Mouse.UnitRay.Direction or Mouse.Hit.lookVector )
You're using the look vector as the direction that the bullet travels in, and not the mouse position. The bullet is travelling in a straight line from the look vector of the humanoid root part, and the orientation doesn't matter for velocity. You can instead do something like this (I'm not that good at scripting this might not work)
Bullet.Position = gunPos Bullet.AssemblyLinearVelocity = (mouse.hit - gunPos).Unit * Speed
Here we get the vector from the gun to the mouse position, and convert it to a unit vector so that the distance of the mouse from the gun doesn't influence the speed, and multiply it by the speed.
Also, if you're using velocity to calculate the bullet's path, it'll be affected by gravity. If you don't want this to happen, you can use raycast for the bullets instead. You can just look at dev forum posts and other scripting helpers questions to help you with that.