Why when clone tools scripts isn't working?

When tools clone in players backpack, then scripts inside tool doesn’t working. Local script inside ScreenGui.Frame.
SCRIPT:local warriorButton = script.Parent.Warrior
local archerButton = script.Parent.Archer
local mageButton = script.Parent.Mage

local replicatedStorage = game:GetService(“ReplicatedStorage”)
local player = game.Players.LocalPlayer
local backpack = player:WaitForChild(“Backpack”)

local function attachToolScripts(tool)
local toolScript = tool:WaitForChild(“Script”)
local clonedScript = toolScript:Clone()
clonedScript.Parent = tool
clonedScript.Disabled = false
end

local function loadPlayer(characterType, itemFolder)
local playerTools = replicatedStorage.Tools[characterType]:Clone()

backpack:ClearAllChildren()

playerTools.Parent = backpack

for _, item in ipairs(itemFolder:GetChildren()) do
	local newItem = item:Clone()
	newItem.Parent = backpack
end

player:LoadCharacter()

for _, tool in ipairs(backpack:GetChildren()) do
	if tool:IsA("Tool") then
		attachToolScripts(tool)
	end
end

end

warriorButton.MouseButton1Click:Connect(function()
player.PlayerGui.ScreenGui.Frame.Visible = false

local itemFolder = game.ReplicatedStorage.Tools.Warrior
loadPlayer("Warrior", itemFolder)

end)

archerButton.MouseButton1Click:Connect(function()
player.PlayerGui.ScreenGui.Frame.Visible = false

local itemFolder = game.ReplicatedStorage.Tools.Archer
loadPlayer("Archer", itemFolder)

end)

mageButton.MouseButton1Click:Connect(function()
player.PlayerGui.ScreenGui.Frame.Visible = false

local itemFolder = game.ReplicatedStorage.Tools.Mage
loadPlayer("Mage", itemFolder)

end)

1 Like

You need to use a remote event when cloning the tools

Because the server side wouldnt be able to see the tools location