Rocket Launcher Doesn't Work

HellO! I’m StarJ3M and I’m trying to make a game cald Ro-Fighters!

I’m currently making weapons, and for some reason my rocket launcher script wont work, I’m trying to make it so that wherever the players mouse is, a projectile will shoot out of the launcher and when it hits something then a sound would play and also a particle will get enabled.

-- Variables
local Players = game:GetService("Players")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Debris = game:GetService("Debris")

local player = Players.LocalPlayer

local character = player.CharacterAdded:Wait()

local Projectile = ReplicatedStorage:WaitForChild("Parts"):WaitForChild("Projectile")

local BlastParticle = ReplicatedStorage:WaitForChild("Particles"):WaitForChild("BlastEffect")

local Debounce = false

local Cooldown = 7

local mouse = player:GetMouse()

local FireSound = script.Parent.Handle:WaitForChild("Fire")

local ExplosionSound = script.Parent.Handle:WaitForChild("Boom")

-- Configure
local con = {
	rocketSpeed = nil;
	damage = function() return math.random(10, 25) end
}

-- Rocket Shot
script.Parent.Activated:Connect(function()
	if not Debounce then
		
		local mousePosition = mouse.Hit
		
		Debounce = true
		
		FireSound:Play()
		
		local ProjectileClone = Projectile:Clone()
		
		ProjectileClone.Name = "Projectile"
		
		ProjectileClone.Parent = game.Workspace
		
		ProjectileClone.Position = script.Parent.FirePart.Position
		
		ProjectileClone.Oreintation = ProjectileClone.Oreintation * mousePosition.LookVector
		
		local BodyMover = Instance.new("BodyForce")
		BodyMover.Name = "BodyForce"
		BodyMover.Parent = ProjectileClone
		BodyMover.Force = Vector3.new(0,20,0)
		
		for i = 1, 500 do
			ProjectileClone.AssemblyLinearVelocity = Vector3.new(mousePosition)
		end
		
		local function ProjectileBlast()
			local Explosion = Instance.new("Explosion")
			Explosion.Name = "Explosion"
			Explosion.Parent = ProjectileClone
			Explosion.Position = ProjectileClone.Position
			
			local ExplosionSoundClone = ExplosionSound:Clone()
			ExplosionSoundClone.Name = "ExplosionSound"
			ExplosionSoundClone.Parent = ProjectileClone
			
			local BlastEffectClone = BlastParticle:Clone()
			BlastEffectClone.Name = "Blast"
			BlastEffectClone.Parent = ProjectileClone
			
			ExplosionSoundClone:Play()
			
			BlastEffectClone.Enabled = true
			wait(0.5)
			BlastEffectClone.Enabled = false
			delay(1)
			delay(3)
			Explosion:Destroy()
			Debris:AddItem(
				ProjectileClone,
				0
			)
			
		end
		
		ProjectileClone.Touched:Connect(ProjectileBlast)
		wait(Cooldown)
		Debounce = false
	end
end)

Their are No Errors.

1 Like

I think I understand what you’re trying to make. Could you please elaborate on what happens instead of what you want it to do?

In the mean time, you can do some debugging. Place prints that output relevant values or just a “hey, this happened!” type of thing at each step to see where exactly your code gets funky. This should help you to isolate the problem more.

2 Likes

Do you mean what happens when it doesn’t work?

Nothing actually even printed itself, that’s strange.

So it seems like that whole thing is just broken.

I enabled it, nothing happened so what was that gonna do?

1 Like

So nothing happens when you click with the rocket launcher?

1 Like

Yes, nothing happens at all, This is inside of a local script and parented to a tool.

Alright, let me copy this into a test place and try to solve the issue so that I can help you. Please stand by!

1 Like

Alright. First and foremost, you’re handling the projectile on the client. Try handling the projectile on the server by sending the necessary information (mouse position, handle position) via a remote event to a server script, which handles the projectile. If you only handle the projectile on the client, no one else will be able to see it.

As for it not doing anything, give me a little while to test your code out and see whats going on.

1 Like