Bullet rotation help

I am working on making guns, I have already made the guns and at this time am trying to make bullets. I have encountered a problem that the bullet needs rotation. I have tried multiple times to change it by getting the rotation of the gun and getting the lookvector of the players camera neither have worked can i get any help?
script:

script.Parent.Bullet.OnServerEvent:Connect(function(player, looker, damage)
	
	local cframe = script.Parent.Handle.CFrame
	
	local bullet = game.ReplicatedStorage.BulletTest:Clone()
	bullet.Parent = game.Workspace.BulletStorage
	bullet.CFrame = cframe
	bullet.Name = player.Name.."'s Bullet"
	bullet.Orientation = Vector3.new(workspace.CurrentCamera.CFrame.LookVector)
	print(bullet.Orientation)
	
	local flyer = Instance.new("BodyForce", bullet)
	flyer.Force = Vector3.new(0, bullet:GetMass() * 150, 0)
	
	bullet.Velocity = looker * 275
	
	bullet.Touched:Connect(function(hit)
		if hit.Name ~= "1911" and hit.Name ~= "Handle" and hit.Name ~= player.Name and hit.Parent.Name ~= player.Name and hit.Name ~= player.name.."'s Bullet" then
			bullet:Destroy()
			if hit.Parent:FindFirstChild("Durability") then
				hit.Parent.Durability.Value -= 1
			end
			if hit.Parent:FindFirstChild("Humanoid") then
				if hit.Parent.Humanoid.Health > 0 then
					if hit.Name == "Head" then
						damage = damage * 2
					else
						damage = damage
					end
					hit.Parent.Humanoid:TakeDamage(damage)
					if hit.Parent.Humanoid.Health <= 0 then
						if hit.Name == "Head" then
							player.CashFolder.Cash.Value = player.CashFolder.Cash.Value + 55
							player.LevelFolder.XP.Value = player.LevelFolder.XP.Value + 35
						else
							player.CashFolder.Cash.Value = player.CashFolder.Cash.Value + 15
							player.LevelFolder.XP.Value = player.LevelFolder.XP.Value + 10
						end
					end
				end
			end
		end
	end)
	
	game.Debris:AddItem(bullet, 8)
	
	wait()
	
end)

Change to

local bullet = game.ReplicatedStorage.BulletTest:Clone()
bullet.Parent = game.Workspace.BulletStorage
local camcf = workspace.CurrentCamera.CFrame
bullet.CFrame = CFrame.fromMatrix(script.Parent.Handle.Position, camcf.RightVector, camcf.UpVector, -camcf.LookVector)
bullet.Name = player.Name .. "'s Bullet"

There are more improvements that could be made to this script, but maybe post in code review for that :slight_smile:

Alright, I will try this out thanks.

I just got home and tested this and it didn’t work. Thanks anyway

It’s not generally advisable to have bullets in flight simulated with parts. You can’t rely on touched events to handle collisions with small parts moving at 275 studs/s, and no one will see the part anyways (just as you would not see a real bullet flying past you). Games normally use raycasting for fast projectiles, and physical parts for slower and/or larger projectiles like rockets and grenades.

1 Like

well thanks for the recommendation, I will see if I can replace the bullets for something like a ray etc.

I’d recommend checking out FastCast. It’s a good open source compromise between fast, efficient raycasting and having a nice trajectory that projectiles provide.