As you can see, when I face a certain direction, it ejects correctly. However, when I turn the opposite way, the bullets eject at another direction than intended.
Here’s my code:
local DebrisService = game:GetService("Debris")
local t = script.Parent
script.Parent.OnServerEvent:Connect(function()
local shell2 = game.ReplicatedStorage.pistol_bullet
local shell = shell2:Clone()
shell.CFrame = t.Parent.Parent.Parts.Bullet.CFrame * CFrame.fromEulerAnglesXYZ(1.5,0,0)
shell.CFrame = t.Parent.Parent.Parts.Bullet.CFrame
shell.Anchored = false
shell.Name = "Shell"
shell.Velocity = t.Parent.Parent.Parts.Bullet.CFrame.lookVector * 7 + Vector3.new(math.random(0,10),20,math.random(0,10))
shell.RotVelocity = Vector3.new(0,100,0)
DebrisService:AddItem(shell, 1)
shell.Parent = game.Workspace
end)