✓ Accepted answer
local player = game.Players.LocalPlayer
local char = player.CharacterAdded:wait()
local mouse = player:GetMouse()
local Bullet = Instance.new("Part",game.Workspace)
local trajectory = CFrame.new(char.HumanoidRootPart.CFrame.p,mouse.Hit.p)
Bullet.Anchored = true
Bullet.CFrame = trajectory
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = Bullet.CFrame.lookVector * 100
Also if you want the bullet to spawn infront of the character replace the following line with this
Bullet.CFrame = trajectory *CFrame.new(0,0,-10)
And if you want the bullet to spawn out of the barrel of the gun, make sure you define it first
local barrel = GUNNAME.Barrel.CFrame.p
local trajectory = CFrame.new(barrel,mouse.Hit.p) * CFrame.new(0,0,-2)
If this helped you, please accept this answer.
2 comments
Use raycasting and make the bullet move along that
Raycasting ?