Tool not working after cloning on server

Hey! I know that there is a lot of posts on this issue already, though, all of them are cloning the tools in a LocalScript. I’m cloning the tools in a ServerScript. The tools are mostly Carbon Engine weapons. Before cloning, they work fine, although after they’re cloned, they do not work anymore. Equipping the tool doesn’t do anything and F9 returns bunch of mostly CE RemoteEvent related errors.

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(p)
	if p then
		p.CharacterAppearanceLoaded:Connect(function()
			local Folder = script:FindFirstChild(p.Team.Name)
			if Folder then
				local Tools = Folder:FindFirstChild("Tools")
				if Tools then
					for i,v in pairs(Tools:GetChildren()) do
						if not p.Backpack:FindFirstChild(v) then
							v:Clone().Parent = p.Backpack
						end
					end
				end
			end
		end)
	end
end)

obrazek

If you trying to move the tools in starterpack, and test them, are they working?

Yes, as I said already, before cloning, it works fine.

Try to add the tools in serverstorage, not in serverscript.

Oh I forgot to mention, it works perfectly in another game, which is pretty weird.

Are the handling scripts in the tool? You might need to code the cloned tool’s functionality.

Everything is indeed in the tools.

You speak about RemoteEvent but you do not show any Remote. The only issue in your current code is p.Backpack:FindFirstChild(v) because you’re sending an instance instead of a string, so you’re always finding nothing.

p.Backpack:FindFirstChild(v.Name):white_check_mark:

I have the impression that your problem does not come from the code you published.

1 Like

Well the main important thing to note is that if there are Scripts in the tool themselves and that original tool is located in a container in which a Script can run (which I’m assuming is ServerScriptService in this case), that Tool script will run and can unintentionally break. Consider moving your assets to ServerStorage in which Scripts with the Legacy RunContext cannot run on and see if that fixes your problems.

2 Likes

Tried putting it into ServerStorage, unfortunately, it did not help either.

That is something we cannot help you with unless you provide an example of those tool scripts.
Are the tool scripts RunContext set to Legacy when you parent them into ServerStorage?

The scripts inside of the tools are ModuleScripts, therefore there is no RunContext property.

So how are they being ran without a script?

That’s not really related to this script at all. As I said already, they’re Carbon Engine weapons. There are other scripts from that official engine.

Maybe but it’s definitely not related to the published code too. Can you show us a screenshot of the output to see the errors?

  1. But it is important. The code you provided shows no signs of breaking the tool themselves.
  2. I have no idea what Carbon Engine is. We need as much context as possible to help you.
  3. You are mentioning the remote errors. What are those errors? What is the code that is throwing those errors?

Hmm, didn’t get any errors rn, which is kinda weird. Tho, there is this warning.

It’s not an error it’s a yield :smiley:

You do not find “Equip” in CarbonResource → Events

I know I didn’t say it’s an error.

Try to remove if p then, in the code.