Shell Ejection System

Hey! I’m making a gun system from scratch and I made 2 lines of code for the ejection:

script.Parent.Velocity = Vector3.new(0,math.random(8, 23),math.random(-5,5))
script.Parent.RotVelocity = Vector3.new(0,math.random(50,300),0)

how would i make this clone the shell mesh to the position of the gun and fire that code when the player clicks while using the gun?

if you need more understanding just reply im bad at explaining stuff

As I’m understanding it you want to clone the shell mesh and shoot it out from the gun each time the player shoots. Assuming you’ve already handled everything else you mentioned (the gun itself) you should just clone the shell mesh from ServerStorage or where-ever you store it. Something really really important to remind you is that the Velocity and RotVelocity properties are deprecated.

One problem I see is that from the context of the code you actually have a script inside each bullet which is definitely concerning so try to launch the shells using the piece of code making the gun go and not from the shell itself.

If you want to give me a script for this here:

local bullet = game.ServerStorage.Bullet
local bulletClone = bullet:Clone()

bulletClone.Position = Vector3.new() --insert gun thing here idk lol
bulletClone.Velocity = Vector3.new(0,math.random(8, 23),math.random(-5,5))
bulletClone.RotVelocity = Vector3.new(0,math.random(50,300),0
-- insert other things here


thank you for your response, im going to try something now, for the position thing i wanted it to clone the shell to the gun yk so the shells come out the side not just in the middle of the void, im just not sure how to send the pos info to the script so the clone spawn at the position of the gun when its fired

any one else got any ideas? im stuck on what to do