I have my own gun script, and I want a shell to eject out of the gun after firing a bullet. I have a script mostly working, but instead of ejecting it, it just kind of drops it onto the ground.

I took a look at Velocity on the wiki, but I'm not quite sure to use it. Any of you mind explaining that or if there's a better way to explain that?

--Eject a shell from a gun
local function onEjectShell(tool, count)
	--Create shell
	local shell = script.Shell:Clone()
	shell.Parent = tool
	
	--Eject shell
	shell.Position = tool.ejector.Position
	shell.Orientation = tool.ejector.Orientation
	
	game:GetService("Debris"):AddItem(shell, 300)
end

5 comments

0

I don't think velolcity is that hard to understand https://www.google.com/search?q=define+velocity

0

I've taken physics, I understand it. I don't understand how ROBLOX does it with Vector3.

0

I see two options here, BodyMovers, and Manually CFraming it.

0

@craft manually* ;) @gitrog You'd want to make the Vector3 be the direction the part is moving in. The bigger the numbers, the higher the velocity.

0

What I'm trying to figure out is how to use velocity to make the direction it fires out relative to the ejector. I always want it to fire out of the right side of the gun, no matter what direction it's facing, which is what I'm not quite sure how to do.