--Launches a rocket.

local function LaunchRocket(Rocket,TargetPos)
	local Character = game.Players.LocalPlayer.Character
	local SpawnPosition = Handle.Position + (Handle.CFrame.lookVector * (Handle.Size.Z/2))
	local BodyVelocity = Rocket:FindFirstChild("BodyVelocity")
	local BodyGyro = Rocket:FindFirstChild("BodyGyro")
	local ExplodeEvent = Rocket:FindFirstChild("Explode")
	Rocket.Velocity = Vector3.new(0,0,0)
	Rocket.CFrame = CFrame.new(SpawnPosition,TargetPos)
	
	--Set the velocity and direction.
	if BodyVelocity and BodyGyro then
		local Direction = (TargetPos - SpawnPosition).unit
		BodyVelocity.Velocity = Direction * ROCKET_LAUNCH_SPEED
		BodyGyro.CFrame = CFrame.new(Vector3.new(0,0,0),Direction)
	end
	
	--Fire the event when touched.
	if ExplodeEvent then
		Rocket.Touched:Connect(function(TouchPart)
			if not IGNORE_LIST[string.lower(TouchPart.Name)] and not TouchPart:IsDescendantOf(Character) then
				ExplodeEvent:FireServer(Rocket.Position)
			end
		end)
	end
end


