Tool not activating after cloning via localscript

  1. What do you want to achieve? inventory system

  2. What is the issue? i cloned a tool from a folder inside the player to the players backpack but it doesn’t activate

  3. What solutions have you tried so far? i search on google but no clear answer

local RS = game:GetService("ReplicatedStorage")
local plrs = game:GetService("Players")
local player = plrs.LocalPlayer
local inv = player:WaitForChild("Inventory")
local lasttool = nil
local lastinv = nil
local function arrange(weapon)
	local item = script.Template:Clone()
	item.Parent = script.Parent
	--item.Price.Text = "$" .. weapon.Config.Price.Value
	item.Name = weapon.Name
	item.NameLbl.Text = weapon.Name
	item.LayoutOrder = weapon.Config.Price.Value

	item.Buy.Activated:Connect(function()
		if item.Buy.Text == "Equip" then		
			item.Buy.Text = "Unequip"
			local a = weapon:Clone()
			a.Parent = player.Backpack
			local b = weapon:Clone()			
			b.Parent = player.StarterGear
			if lasttool ~= nil then
				
				player.Backpack:FindFirstChild(lasttool):Destroy()
			end
			if lastinv ~= nil then
				player.PlayerGui.Gui.Inventory.Inv:FindFirstChild(lastinv).Buy.Text = "Equip"
				player.StarterGear:FindFirstChild(lastinv):Destroy()
			end		
			lasttool = a.Name
			lastinv = b.Name		
		else
			item.Buy.Text = "Equip"
			player.Backpack:FindFirstChild(weapon.Name):Destroy()
			player.StarterGear:FindFirstChild(weapon.Name):Destroy()
			if lasttool == weapon.Name then
				lasttool = nil
			end
			if lastinv == weapon.Name then
				lastinv = nil
			end
		end	
	end)
end

for i, tool in ipairs(inv:GetChildren()) do
	arrange(tool)
end

inv.ChildAdded:Connect(function(tl)
	arrange(tl)
end)

You need to use remote events or remote functions to do it, because local script is only for client not for server.

As @mpc19801981 said, you need to use a RemoteEvent to tell the server to clone the tool to the Player’s backpack. Tools will not work if you clone them with a LocalScript.