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

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
