Roblox Shell Ejection

hey so currently im making a gun system from scratch, i just made a shell ejection system, heres the code:

bulletClone.Parent = game.Workspace.CasingCache

bulletClone.Velocity = Vector3.new(0, math.random(8, 23), math.random(-35, -25))
bulletClone.RotVelocity = Vector3.new(0, math.random(50, 300), 0)

the only issue with this code is the fact that she shells always eject to one side of the map, for example any way i face even forwards the shells will only travel in that one direction, if you know how to fix this please tell me!

1 Like

Is it because you aren’t rotating your shell casing in the direction the gun is facing.
Or is it because you are providing a Vector3.new that is in World space, not Object space?

If you are just cloning the casing to the workspace, then it’s pointing the direction of the casing that you are cloning from.

how would i do this? the casing its self is fine its just the direction its going in always stays the same so if i face to the left it always flies right.

It ejects in the same direction because the velocity is relative to the world space, as already mentioned.
I’d recommend using the CFrame’s vector properties.

local shell = gun.Shell
local velocity = 8
bulletClone.Velocity = shell.CFrame.RightVector * velocity

CFrame.RightVector

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.