--Main function

local function AttachAuraControl(source_part, eff_cont) --(source_part, effect_container)
	
	local AnimObj
	
	local function Start()
		AnimObj = {}
		AnimObj["LastUpdate"] = tick()
		
		local char = source_part.Parent
		AnimObj["RootPart"] = char:FindFirstChild("HumanoidRootPart")
		
		AnimObj["Parts"] = {}
		
		for i = 1, 4 do
			local np = EFFECT_LIB.NewInvisiblePart()
			np.Transparency = 0.2
			np.Material = "Neon"
			
			local knife_mesh = Instance.new("BlockMesh")
			knife_mesh.Scale = Vector3.new(15, 2, 15)
			knife_mesh.Parent = np
			
			AnimObj["Parts"][i] = np
	
			np.Parent = eff_cont
		end
	end
	
	local function Update()
		
		local base_cf
		if AnimObj["RootPart"] == nil then
			base_cf = source_part:GetRenderCFrame()
		else
			base_cf = AnimObj["RootPart"]:GetRenderCFrame()
		end
		
		local loop = EFFECT_LIB.Loop(.85)
		AnimObj["Parts"][1].CFrame = base_cf * CFrame.new(-1.6, -3, -1.6)
		AnimObj["Parts"][2].CFrame = base_cf * CFrame.new(-1.6, -3, 1.6)
		AnimObj["Parts"][3].CFrame = base_cf * CFrame.new(1.6, -3, 1.6)
		AnimObj["Parts"][4].CFrame = base_cf * CFrame.new(1.6, -3, -1.6)
		
		local color1
		local color2
		if loop >= 0 and loop <= 0.1 then
			color1 = BrickColor.new("Hot pink")
			color2 = BrickColor.new("Lime green")
		end
		if loop > 0.1 and loop <= 0.5 then
			color1 = BrickColor.new("Eggplant")
			color2 = BrickColor.new("Forest green")
		end
		if loop > 0.5 and loop <= 0.6 then
			color2 = BrickColor.new("Hot pink")
			color1 = BrickColor.new("Lime green")
		end
		if loop > 0.6 then
			color2 = BrickColor.new("Eggplant")
			color1 = BrickColor.new("Forest green")
		end
		
		AnimObj["Parts"][1].BrickColor = color1
		AnimObj["Parts"][2].BrickColor = color2
		AnimObj["Parts"][3].BrickColor = color1
		AnimObj["Parts"][4].BrickColor = color2
	end
	
	local function Stop()
		eff_cont:ClearAllChildren()
		AnimObj = nil
	end
	
	return {Start = Start, Update = Update, Stop = Stop}
end

return AttachAuraControl
