Why do the bullet casings eject correctly only when you're facing a certain direction?

Here’s what it looks like: https://gyazo.com/eefc486eea459b84cbd82face315737c

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)
1 Like

shell.CFrame = t.Parent.Parent.Parts.Bullet.CFrame * CFrame.fromEulerAnglesXYZ(1.5,0,0)
shell.CFrame = t.Parent.Parent.Parts.Bullet.CFrame

I’m not great with scripting, but aren’t you setting the shell.CFrame twice, once right after the other?

Maybe you set the shell CFrame twice, try removing the lower line.

1 Like

Doesn’t work. (30 charactersssssss)

It has something to do with this line

shell.Velocity = t.Parent.Parent.Parts.Bullet.CFrame.lookVector * 7 + Vector3.new(math.random(0,10),20,math.random(0,10))

Nvm i fixed it. (30 characters)

1 Like

what did you fix on that line

one
two
three
four
five
six
seven

They probably figured out the difference between ToWorldSpace and ToObjectSpace:

i just ended up using lookvector and some module scripts :skull: