What solutions have you tried so far?
I’ve tried seeking for help in many different sites such as dev hub, but I didn’t found any useful information for my current problem
Here’s the code
local function eject()
local shell = game.ReplicatedStorage.MainServer.FX.BulletShells.MP7:Clone()
shell.Parent = workspace
local shellPos = arms.MP7.SlideSmoke.Pos.WorldPosition
shell.Position = Vector3.new(shellPos.X, shellPos.Y, shellPos.Z)
shell.CanCollide = true
shell.Anchored = false
shell.Velocity = (arms.MP7.SlideSmoke.CFrame.rightVector) * .5 + Vector3.new(0,math.random(20, 30),math.random(5,10))
shell.RotVelocity = Vector3.new(0,math.random(50,300),0)
end
you are looking for “VectorToObjectSpace”, you’ll need to access the gun’s cframe to use it, then use the vector you intend as a argument. here’s a example:
local CasingVelocity = Vector3.new(5,0,0)
shell.Velocity = Gun.CFrame:VectorToWorldSpace(CasingVelocity)
you might also want to consider using the Debris service as that’ll delete the bullet casing without having to write a separate script with wait() in it for the bullet casing:
local DebrisService = game:GetService("Debris")
local DeleteTime = 4
DebrisService:AddItem(BulletCasing, DeleteTime)