Tool not functioning when cloned to players backpack

Hi, so I’m trying to clone a tool to players backpack but when the tool cloned to backpack it’s not working.But it’s working when i just put the tool to StarterPack.

This tool works with Hitbox System. So, I’m using a RemoteEvent.
And I clone the tool with server script, not with local script.

image

This is the tool.Tool is in ServerStorage.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		script.Parent.MouseClick:Connect(function(hit)
		local backpack = player:WaitForChild("Backpack")
		local cloneTool = game:GetService("ServerStorage")["Tactical Knife"]:Clone()
		cloneTool.Parent = backpack
		end)
	end)
end)

this is how I clone the tool. It seems to work.
image
And the Hitbox System script. It’s in ServerScriptService, RemoteEvent is in ReplicatedStorage.

I can send more information if it’s need.

1 Like

when you place it in StarterPack you are not cloning it, right?
When you are placing it in backpack you are cloning it.

Sounds like the issue could be on connections? references? yes, provide more details as the local scripts and server script in tool

1 Like

I’m not 100% sure what your trying to explain here can you give me a little bit more information its confusing to understand on my end.

1 Like

The cloning of tools has to happen server-sided. Doing it local-sided will cause communication issues. If you do, the server does not know the player has the item equipped, because it never cloned it. Thus trying to activate the tool after you clone it locally, the server will not listen as the item does not exist on the server.

2 Likes

I had assumed that you were cloning the tool from a server script. You says its in ServerStorage, trying to cloning it from a local script makes no sense.

But, after reading @Iemny reply I checked your “server script” and seems like its in ServerScriptService and called “PunchServer”?

In which script.Parent.MouseClick is expecting a click on the ServerScriptService to clone the tool. ServerScriptService cant be clicked…

Or this script is in part of workspace with a click detector, or the script is a local script?
The script makes no real sense

1 Like

okay so.
this script is in a part with ClickDetector (I didn’t wrote that sorry):

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		script.Parent.MouseClick:Connect(function(hit)
		local backpack = player:WaitForChild("Backpack")
		local cloneTool = game:GetService("ServerStorage")["Tactical Knife"]:Clone()
		cloneTool.Parent = backpack
		end)
	end)
end)

and the script is in ServerScriptService is a Hitbox script that welds a part to player to damage the other player that touches the part.
This is the script:

local rs = game:GetService("ReplicatedStorage")

local events = rs:WaitForChild("Events")
local hitboxEvent = events:WaitForChild("Hitbox")

function newHitbox(character, size, offset, damage, linger)
	local hrp = character:FindFirstChild("HumanoidRootPart")
	if hrp == nil then return end
	local weld = Instance.new("WeldConstraint", hrp)
	local hitbox = Instance.new("Part")
	weld.Part0 = hrp
	weld.Part1 = hitbox

	hitbox.Transparency = 1
	hitbox.CanCollide = false
	hitbox.CanQuery = false
	hitbox.Massless = true

	hitbox.Size = size
	hitbox.CFrame = hrp.CFrame + hrp.CFrame.LookVector * offset.X + Vector3.new(0,offset.Y)
	hitbox.Parent = character

	hitbox.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") == nil then return end

		for _, v in pairs(hitbox:GetChildren()) do
			if v:IsA("ObjectValue") then
				if v.Value == hit.Parent then return end
			end
		end
		local hitCounter = Instance.new("ObjectValue", hitbox)
		hitCounter.Value = hit.Parent

		hit.Parent.Humanoid:TakeDamage(damage)
	end)

	game.Debris:AddItem(hitbox, linger)
end

hitboxEvent.OnServerEvent:Connect(function(plr, size, offset, damage, linger)
		newHitbox(plr.Character, size, offset, damage, linger)
end)

and the LocalScript is in the tool:

local cas = game:GetService("ContextActionService")
local rs = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")

local events = rs:WaitForChild("Events")
local hitboxEvent = events:WaitForChild("Hitbox")

local plr = game.Players.LocalPlayer
plr.CharacterAdded:Connect(function(char)w
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")

local currentPunch = 0
local lastPunch = 0

local debounce = false
script.Parent.Activated:Connect(function(hit)		
	if debounce then return end
	if tick() - lastPunch > 1.5 then
		currentPunch = 0
			end
	debounce = true
	if currentPunch == 0 then
		local rightPunch = hum:LoadAnimation(script:WaitForChild("RightPunch"))
			rightPunch:Play()
			wait(0.4)
		hitboxEvent:FireServer(Vector3.new(3,3,2), Vector3.new(2), 20, 0.3)
		task.wait(0.7)
		debounce = false
	elseif currentPunch == 1 then
		local leftPunch = hum:LoadAnimation(script:WaitForChild("LeftPunch"))
			leftPunch:Play()
			wait(0.4)
		hitboxEvent:FireServer(Vector3.new(3,3,2), Vector3.new(2), 20, 0.3)
		task.wait(0.7)
		debounce = false
	elseif currentPunch == 2 then	
		local rightPunch = hum:LoadAnimation(script:WaitForChild("RightPunch"))
			rightPunch:Play()
			wait(0.4)
		hitboxEvent:FireServer(Vector3.new(3,3,2), Vector3.new(2), 20, 0.3)
		task.wait(0.7)
		debounce = false
	end
	if currentPunch == 2 then
		currentPunch = 0
	else
		currentPunch += 1
	end
lastPunch = tick()
     end)
end)

And it works when i just use it from StarterPack.
But it doesn’t when cloning it.
Tool clones but it’s not working.And there is no errors.