Projectile Script Not Working

Im trying to make a guided projectile, this script is supposed to make it so when a player click on their screen then, a projectile will pop up in the rocket blasting out to the mouse position ( basically the Roblox rocket )

-- 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
			task.wait(0.5)
			BlastEffectClone.Enabled = false
			
			Debris:AddItem(Explosion, 1)
			Debris:AddItem(ProjectileClone,	0)
			
		end
		
		ProjectileClone.Touched:Connect(ProjectileBlast)
		wait(Cooldown)
		Debounce = false
	end
end)

This Doesn’t work at all, theirs no errors in the output earthier

2 Likes

Add print statements to further pinpoint where the exact issue is

Also you never really specified what’s wrong with the script, can you give us a bit more information on what’s not working exactly?

-- 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")

print("We know this 100% works")

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

-- Rocket Shot
script.Parent.Activated:Connect(function()
    print("This has been activated/fired")

	if not Debounce then
		print("Firing the projectile")
		
		local mousePosition = mouse.Hit.Position
		
		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 = 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
			task.wait(0.5)
			BlastEffectClone.Enabled = false
			
			Debris:AddItem(Explosion, 1)
			Debris:AddItem(ProjectileClone,	0)
		end
		
		ProjectileClone.Touched:Connect(ProjectileBlast)
		wait(Cooldown)
		Debounce = false
	end
end)
2 Likes

Sorry about that, I have been dying currently

Look at the updated version

and yes I am messaging you at 12:53 because why not