How would I do BulletDrop?

Hello there, In my guns system I’ve recently thought about adding bullet drops to it. But I have no idea how to.

So basically when the player fires the gun, the shell/Bullet comes out of it and falls onto the ground.

I have no idea whatsoever on how to do that, looking around the forum didn’t help because most posts were about the bullet losing air/falling down while in the air.

I just need a way of doing it, thanks.

Any help is appreciated!

1 Like

Do you want the gun just to fire and it just comes out of the bullet and falls to the ground? Or do you want it to fire and then it slowly loses height while in air. Because I don’t really understand your question.

I want it to come out of the bullet and fall to the ground.

Well you could just clone the bullet, and set the position to the front of the gun by finding the vector3 position in your script and then assigning the bullet position to that position, then just un-anchoring the bullet. Which would allow it to fall to the ground. If you would like something like that I can give you an example. (Meaning a script example)

If you’re able to give me a example then I wouldn’t mind.

First you’d get the mouse:

local Player = Game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.Button1Down:Connect(function()
     game.ReplicatedStorage.FireGun:FireServer()
end)

You’d fire the RemoteEvent, which spawns an unanchored bullet (Just cloning and then changing position with a Vector3)

1 Like

And how would I calculate the vector3?

Local Script In The Tool Handle

local Player = game.Players.LocalPlayer --Gets local player
local Mouse = Player:GetMouse() --Gets the Mouse and defines it as mouse
local Tool = script.Parent.Parent --Defines tool as the parent of the parent of the script.
local Activated = false --True or false value

Tool.Equipped:Connect(function() --If the tool is equipped connect it to a function
	Activated = true --Changes the Activated value to true
end)

Tool.Unequipped:Connect(function() --If the tool is unequipped, connect it to a function
	Activated = false --Change the Activated value to false
end)
Mouse.Button1Down:Connect(function() --If there is a click, connect it to a function
	if Activated == true then --If the variable Activated is true then it continues
		game.ReplicatedStorage.FireGun:FireServer() --Fires the RemoteEvent.
	end
	
end)

Script in the Tool Handle - This defines the RemoteEvent

game.ReplicatedStorage.FireGun.OnServerEvent:Connect(function(player, part)  --When the RemoteEvent is fired, connect it to a function. Player is the the player so it would print your player name. Part would likely be nil if you printed it.
	local PlayerName = player.Name --Gets the player name
	local FindGun = game.Workspace:FindFirstChild(PlayerName):WaitForChild("Gun") --Defines how to find the gun.
	if FindGun ~= nil then --If it finds the gun
		local SpawnBullet = game.Workspace.Bullet:Clone() --Defines SpawnBullet as a clone of the bullet in workspace.
		SpawnBullet.Position = Vector3.new(FindGun.Handle.Position.X,FindGun.Handle.Position.Y, FindGun.Handle.Position.Z ) --Changes the position of the bullet to the Handle of gun
		SpawnBullet.Parent = game.Workspace --Puts it in the workspace so you can see it.
		SpawnBullet.Anchored = false --Changes it to unanchored so it falls to the ground.
	end
end)

You would first find the player, then look for them in the workspace. Then find the tool, then the position.

Note: You will need a bullet model in the workspace, or ServerStorage, if you’d like. And a remoteEvent in Replicated Storage. You can edit this script as you’d like. If you don’t understand anything, please ask.

An image for reference.

What you could do is have H be a random value and t be twice the distance from the gun and the mouse hit

Alternatively just use my Math++ library

No, I mean like bullet drop, like the shell drops out of a gun. Not while the bullet is in the air it loses trajectory.