How to make a bomb gun?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a bomb gun, kind of like this:

  2. What is the issue? Include screenshots / videos if possible!
    I don’t know how to make this.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried making an explosion on the player when they mouse.Button1Down with the gun out.

Thanks!

2 Likes

Clearly know that is Karlson by Dani


I would say you can take a grenade from the toolbox and experiment with the script’s so you can try and learn.

1 Like

I would suggest working up to making something like this, perhaps working on something less complicated to practice and learn. There are tutorials on the DevForum, and YouTube tutorials teaching how to make a gun. This wouldn’t be much different, you would just add an explosion at the point the bullet hits.

2 Likes

you could use a ray cast gun and instance an explosion at the end of the ray cast you can check out the grenade launcher model made by roblox

I tried that, but it kills you.

Yes but this would kill the player, not boost them upwards.

Set the blast pressure of the explosion to 0 and experiment with BodyPositions and BodyGyros.

1 Like

Ok I will try that later. Thanks!

This is the best title for a question that I’ve read all day.

2 Likes

You could use a BodyForce object, and set the force upon the explosion. You could have a kind of “Algorithm” to figure out the force, and then apply it:

local explosionPos = Vector3.new(0,0,0) --Set to the actual explosion position, or use a variable you already have
local player = game.Players:WaitForChild("YourUsername")--Find the player however you want to, you could just iterate through all of the players.

local Debris = game:GetService("Debris")

local explosionPower = 100000

local function applyExplode(plr)
	
	local character = plr.Character or plr.CharacterAdded:Wait() --Getting the character
	local HRM = character:WaitForChild("HumanoidRootPart")
	
	local newC = CFrame.lookAt(explosionPos, HRM.Position)
	local rot = newC.LookVector
	local dist = (explosionPos - HRM.Position).magnitude

	local force = rot * (explosionPower / dist)
	print(force)
	
	local bodyF = Instance.new("BodyForce", HRM)
	
	bodyF.Force = force
	Debris:AddItem(bodyF, 2)
end

wait(4)
print("Exploding")
wait(1)
applyExplode(player)

This applies an “explosion” from the point 0,0,0. Set the player to yourself and try it out. You can tweak it however you need. If I were you, I’d put it in a server script with the explosions, and have a for loop run, calculating this for each player. This also does not do anything rotation wise, and it doesn’t turn the player into a ragdoll, both of which are things you may want.

If you have any other questions please let me know.

1 Like

Yeah, how do you NOT click on that title?

1 Like

That script doesn’t seem to be working… only prints out some position stuff.