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