Issue making rocket launcher

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 a rocket launcher that if the rocket touches something, and that something is a part it will get un-anchored
  2. What is the issue? Include screenshots / videos if possible!
    The rocket explodes, but nothing else happens.
    Video link here: https://drive.google.com/file/d/1v_JIt69GNbi2e9l_iUl10cYjNsBFzNE4/view?usp=sharing
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked on some discord servers for ROBLOX devs.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Here is the script:

local Tool = script.Parent
local Rocket = game.ReplicatedStorage.Part

local Event = game.ReplicatedStorage.RemoteEvent

local Destroyed = false

Event.OnServerEvent:Connect(function(Player, direction)
	local RocketClone = Rocket:Clone()
	RocketClone.Parent = game.Workspace
	RocketClone.CFrame = Tool.Handle.CFrame
	RocketClone.Touched:Connect(function(hit)
			hit.Anchored = false
	end)
	
	local BV = Instance.new("BodyVelocity", RocketClone)
	BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	BV.Velocity = direction.lookVector * 30
	RocketClone.Touched:Connect(function(hit)
		if hit ~= Tool.Handle and not Tool.Parent:FindFirstChild(hit.Name) then
			hit.Anchored = false
		local Explosion = Instance.new("Explosion")
			Explosion.Parent = workspace
			Explosion.Position = RocketClone.Position
			RocketClone:Destroy()
			end
		end)
	end)

Tell me if you want the local script to.

2 Likes

Just use the time formula to see when it should hit:
Distance / Speed = Time

Those stuff always confuses me, I will try to understand.

1 Like

It’s okay. Just do wait(distance / speed) and just create the explosion right after it.

How would I get the distance then?

1 Like

(mouseHit - handle.Position).Magnitude

Still don’t understand, I might have to think about some other solution myself.

1 Like

Can you send the Local Script?

Change it to the Local Script:

local Tool = script.Parent

local Handle = Tool:WaitForChild(“Handle”)

local Rocket = game.ReplicatedStorage.Part

local Event = game.ReplicatedStorage.RemoteEvent

local Player = game.Players.LocalPlayer

local Mouse = Player:GetMouse()

local Cooldown = 10

local Debounce = true

Tool.Activated:Connect(function()

local Humanoid = Tool.Parent:FindFirstAncestorWhichIsA(“Humanoid”)

if Debounce then

Debounce = false

Event:FireServer(Mouse.Hit.p)

wait(2)

Debounce = true

end

end)

When I do Mouse.Hit.p it says lookVector is not a valid member of Vector3.

Send me the updated Server Script

I changed it back because it was better before, then it at least exploded.

Change your server script to this then:

local Tool = script.Parent
local Rocket = game.ReplicatedStorage.Part

local Event = game.ReplicatedStorage.RemoteEvent

local Destroyed = false

Event.OnServerEvent:Connect(function(Player, direction, mouseHit)
local RocketClone = Rocket:Clone()
RocketClone.Parent = game.Workspace
RocketClone.CFrame = Tool.Handle.CFrame
RocketClone.Touched:Connect(function(hit)
hit.Anchored = false
end)

local BV = Instance.new(“BodyVelocity”, RocketClone)
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = direction.lookVector * 30
RocketClone.Touched:Connect(function(hit)
if hit ~= Tool.Handle and not Tool.Parent:FindFirstChild(hit.Name) then
hit.Anchored = false

    wait(mouseHit - script.Parent.Handle.Position).Magnitude / 150)

  local Explosion = Instance.new("Explosion")
  	Explosion.Parent = workspace
  	Explosion.Position = RocketClone.Position
  	RocketClone:Destroy()
  	end
  end)

end)

And also, in your local script, send 2 arguments: Direction and mouse.Hit.p

Unexpected unicode Character it says.

1 Like

I’m right now making a rocket luncher, brb.

Alright, Thought this would be a lot easier at first.

I almost finished it, just a second.

2 Likes

Just a short example of how you can make it:
Rocket luncher (1).rbxl (37.5 KB)

To much math for my brain, to much math of that kind I am bad at. Well thank you anyways. I was hoping for a bit less complicated way. I will mark this as the solution and just try to get all that information in my head.

1 Like

Same. Making guns in Roblox do require some understanding of mathematics, but as you improve it gets simpler. Good luck! :slight_smile: