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.
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!