--Cool Sword of Light transport process


local Properties = {
	TravelTime = 1,
	OrbSpread = 25
}

function Create(ty)
	return function(data)
		local obj = Instance.new(ty)
		for k, v in pairs(data) do
			if type(k) == 'number' then
				v.Parent = obj
			else
				obj[k] = v
			end
		end
		return obj
	end
end

local Character = script:WaitForChild("Character").Value

local Humanoid = Character:FindFirstChildOfClass("Humanoid")

local Center = Character:WaitForChild("HumanoidRootPart")

local LightEffects = script:WaitForChild("LightEffects"):GetChildren()

local TargetLocation,Range = script:WaitForChild("TargetLocation"),script:WaitForChild("Range") --Assumes this is present

local Bezier = script:WaitForChild("BezierCurves")

if not TargetLocation or not Range or not Bezier or not Center then script:Destroy() end

Range = Range.Value

TargetLocation = Center.Position + ((TargetLocation.Value + Vector3.new(0,3,0)) - Center.Position).Unit * math.clamp(((TargetLocation.Value + Vector3.new(0,3,0)) - Center.Position).Magnitude,0,Range)

local Services = {
	Players = (game:FindService("Players") or game:GetService("Players")),
	RunService = (game:FindService("RunService") or game:GetService("RunService")),
	Debris = (game:FindService("Debris") or game:GetService("Debris")),
	Lighting = (game:FindService("Lighting") or game:GetService("Lighting")),
	ServerScriptService = (game:FindService("ServerScriptService") or game:GetService("ServerScriptService")),
	ServerStorage = (game:FindService("ServerStorage") or game:GetService("ServerStorage"))
}

Bezier = require(Bezier)

local Seed = Random.new()

local LightBall = Create("Part"){
	Locked = true,
	Anchored = true,
	CanCollide = false,
	Shape = Enum.PartType.Ball,
	Name = "Light Orb",
	Size = Vector3.new(1,1,1) * Seed:NextNumber(2,3),
	Material = Enum.Material.Neon,
	Color = Color3.fromRGB(255,255,203),
	TopSurface = Enum.SurfaceType.Smooth,
	BottomSurface = Enum.SurfaceType.Smooth
}

local AttachmentA = Create("Attachment"){
	Position = Vector3.new(0,LightBall.Size.Y/2,0),
	Name = "AttachmentA",
	Parent = LightBall
}

local AttachmentB = AttachmentA:Clone()
AttachmentB.Name = "AttachmentB"
AttachmentB.Position = Vector3.new(0,-LightBall.Size.Y/2,0)
AttachmentB.Parent = AttachmentA.Parent

for i=1,#LightEffects do
	LightEffects[i].Parent = LightBall
	LightEffects[i].Enabled = true
	if LightEffects[i]:IsA("Trail") then
		LightEffects[i].Attachment0 = AttachmentA
		LightEffects[i].Attachment1 = AttachmentB
	end
end
