----


local GEAR_NAME = script.Parent.Name

local function GEAR_CONTROL(gear_functions)
	local GF = gear_functions
	
	--Tool variables
	local TLV = {}
	local TConnections = {}
	
	--Tool functions
	
	--Tool object functions
	local function Start()
		--forming classical tool
		TLV["Equipped"] = false
				
		TLV["Tool"] = Instance.new("Tool")
		TLV["Tool"].CanBeDropped = false
		TLV["Tool"].Name = ""
		TLV["Tool"].TextureId = "rbxassetid://"
		--TLV["Tool"].Grip = CFrame.new(0, -0.7, 0.1, 1, 0, 0, 0, 1, 0, 0, 0, 1)
		
		TLV["Handle"] = GF.GenPart()
		TLV["Handle"].Name = "Handle"
		TLV["Handle"].Parent = TLV["Tool"]
		
		--[[
		local h_mesh = Instance.new("SpecialMesh")
		h_mesh.MeshType = "FileMesh"
		h_mesh.MeshId = "rbxassetid://"
		h_mesh.TextureId = "rbxassetid://"
		h_mesh.Scale = Vector3.new(1, 1, 1)
		h_mesh.Parent = TLV["Handle"]
		--]]
		
		--[[
		TLV["Sound"] = Instance.new("Sound")
		TLV["Sound"].Volume = 1
		TLV["Sound"].SoundId = "rbxassetid://"
		TLV["Sound"].Parent = TLV["Handle"]
		--]]
		
		--adding tool to backpack
		TLV["Tool"].Parent = GF.GetBackpack()
		
		--tool triggers
		
		--tool connections
		table.insert(TConnections, TLV["Tool"].Activated:connect(function()
			if not GF.CheckAlive() then return end
			
		end))
		table.insert(TConnections, TLV["Tool"].Equipped:connect(function()
			TLV["Equipped"] = true
		end))
		table.insert(TConnections, TLV["Tool"].Unequipped:connect(function()
			TLV["Equipped"] = false
		end))
		
	end
	
	local function Update() --"return false" to destroy gear control object
		
		return true
	end
	
	local function Stop()
		if TLV["Tool"] ~= nil then
			TLV["Tool"]:Destroy()
		end
		
		for _, conn in pairs(TConnections) do
			pcall(function()
				conn:disconnect()
			end)
		end
		
		TLV = nil
	end
	
	return {Start, Update, Stop}
end

local function GEAR_EFFECT_LOCAL(gear_functions, effect_data)
	local GF = gear_functions
	local ED = effect_data --DESCRIBE EFFECT DATA VALUES BELOW
	
	--Effect variables
	local EV = {}
	
	--Client effect functions
	
	--Client effect object functions
	local function Start()
		EV["StartTime"] = tick()
		
	end
	
	local function Update(in_game) --"return false" to destroy gear effect object
		
		return true
	end
	
	local function Stop()
		EV = nil
	end
	
	return {Start, Update, Stop}
end

return {GEAR_CONTROL, GEAR_EFFECT_LOCAL}
