Projectile=function(G,v)local d=ServerStorage.Models.ManaBolt:Clone()d.Parent=workspace.Debris d.CFrame=G["\077\097\110\097 \077\105\115\115\105\108\101 \083\116\097\102\102"].Top.CFrame game.Debris:AddItem(d,10)local l=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")l.P=math.huge l.Velocity=(v-d.CFrame.Position).unit*100 l.Parent=d local C C=d.Hitbox.Touched:Connect(function(v)local l=v.Parent if not l then return end if l:FindFirstChild("\072\117\109\097\110\111\105\100")and(l~=G and l.Parent==workspace.Enemies)then C:Disconnect()l.Humanoid:TakeDamage(25)d.Hit:Play()d.Bolt:Destroy()d.ParticleEmitter:Destroy()d.Anchored=true task.wait(1)d:Destroy()elseif v.Anchored==true then C:Disconnect()d.Hit:Play()d.Bolt:Destroy()d.ParticleEmitter:Destroy()d.Anchored=true task.wait(1)d:Destroy()end end)end


Projectile = function(Character, MousePosition)
	-- turn to cursor

	local Projectile = ServerStorage.Models.ManaBolt:Clone()
	Projectile.Parent = workspace.Debris
	Projectile.CFrame = Character["Mana Missile Staff"].Top.CFrame
	game.Debris:AddItem(Projectile, 10)

	local ProjectileVelocity = Instance.new("BodyVelocity")
	ProjectileVelocity.P = math.huge
	-- Shoot towards victim humanoidrootpart
	ProjectileVelocity.Velocity = (MousePosition - Projectile.CFrame.Position).unit * 100
	ProjectileVelocity.Parent = Projectile

	local Connection
	Connection = Projectile.Hitbox.Touched:Connect(function(Hit)
		local HitCharacter = Hit.Parent
		if not HitCharacter then return end
		if HitCharacter:FindFirstChild("Humanoid") and HitCharacter ~= Character and HitCharacter.Parent == workspace.Enemies then

			Connection:Disconnect()
			HitCharacter.Humanoid:TakeDamage(25)

			Projectile.Hit:Play()
			Projectile.Bolt:Destroy()
			Projectile.ParticleEmitter:Destroy()
			Projectile.Anchored = true
			task.wait(1)
			Projectile:Destroy()

		elseif Hit.Anchored == true then

			Connection:Disconnect()

			Projectile.Hit:Play()
			Projectile.Bolt:Destroy()
			Projectile.ParticleEmitter:Destroy()
			Projectile.Anchored = true
			task.wait(1)
			Projectile:Destroy()

		end
	end)
end


