Rocket launcher works but always kills whoever that is holding it

So I have a rocket launcher tool here, and it works. But however, the missle explodes and kills whoever is holding it. For instance, your holding the rocket launcher, you activate the tool, and the missle touches you and you get killed. I want it to not kill whoever is holding it and only explodes whenever they hit a part.

Here is how it looks like.
image

Local script:

local tool = script.Parent
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local handle = tool.Handle
local db = false

tool.Activated:Connect(function()
	local hum = tool.Parent:FindFirstChild("Humanoid")
	if hum and db == false then
		db = true
		local mousePos = mouse.Hit.Position
		tool.SendSignal:FireServer(mousePos)
		wait(10)
		db = false
	end
end)

SignalHandle:

script.Parent.SendSignal.OnServerEvent:Connect(function(plr, pos)
	local handle = script.Parent.Handle
	
	-- start to make the missle
	local missle = Instance.new("Part")
	missle.CFrame = CFrame.new(handle.Position,pos)
	missle.Size = Vector3.new(1,1,2)
	missle.BrickColor = BrickColor.new("Really red")
	
	local bodyVelocity = Instance.new("BodyVelocity")
	bodyVelocity.Parent = missle
	bodyVelocity.Velocity = (pos - handle.Position).Unit * 25
	bodyVelocity.MaxForce = Vector3.new("inf","inf","inf")
	
	local pointLight = Instance.new("PointLight")
	pointLight.Brightness = 100000
	pointLight.Parent = missle
	missle.Parent = workspace
	
	missle.Touched:Connect(function(hit)
		if hit ~= handle and not script.Parent.Parent:FindFirstChild(hit.Name) and hit.Parent ~= script.Parent.Parent then
			local explosion = Instance.new("Explosion")
			explosion.Parent = workspace
			explosion.Position = missle.Position
			missle:Destroy()
		end
	end)
end)

Send help!

1 Like

To confirm, what is the parent of the Rocket Launcher tool?

1 Like

Oh, it is a tool that shoots out the bullet. I don’t know what you meant by that.

1 Like

What place is the Rocket Launcher tool in? e.g Workspace/ServerStorage

It is in StarterPlayer. I put it there.

The issue is that you are adding a new explosion. An explosion effect will kill you. Find more information here. Explosion | Documentation - Roblox Creator Hub

Yeah I know, but I want the explosion effect only explodes when it hits other parts, and not whoever is holding it.

If possible, could you provide a GIF of what’s happening when you test the tool?

Oh well, it’s broken. I can’t shoot anymore. Can you help me test it?

I don’t know if this is what your looking for
but i hope it helps

Code:

local Explotion = Instance.new("Explosion")
Explotion.BlastRadius = 20
Explotion.DestroyJointRadiusPercent = 0
Explotion.Position = Character.PrimaryPart.Position
Explotion.Parent = Character

Explotion.Hit:Connect(function(part)
	if part.Parent:FindFirstChild("Humanoid") then
		if part.Parent ~= Character then
			part.Parent.Humanoid:TakeDamage(100)
		end
	end
end)

I changed the DestroyJointRadiusPercent so that the players would not get killed by the explotion

then i used the Hit event of the explotion to check if the explotion hit the player’s character or another player’s character

I hope it helps

2 Likes

This is not what I wanted. I said I want it to explode when it touches a part, not only explodes when it hits a humanoid.

If you paste my script in to yours, then the explotion will still happend.

just the difference is that it will not kill the player that fired the rocket

You may want to set the DestroyJointRadiusPercent of the explosion to 0