Cloned tools stop working

Hello, I am making a system that auto-assigns players to a team. And if you’re on a certain team it will give you a sort of starter pack. This is all done on a server sided script. I have tried looking up this problem, however the solutions for them didnt seem to work for me. The cloned tools contain a localscript and a normal script, both cease to work upon being cloned and parented.

local players = game:GetService("Players")
local teams = game:GetService("Teams")
local pack = game:GetService("ServerStorage"):WaitForChild("Weapons"):WaitForChild("GuardStarterPack")
local maxplayersguards = 6
local guy

players.PlayerAdded:Connect(function(player)
	local amount = 0
	for i,v in pairs(teams.Guards:GetPlayers()) do
		wait()
		amount = amount + 1
	end
	if amount < maxplayersguards then
		player.Team = teams.Guards
		local stor = game:GetService("ServerStorage")
		local char = stor.Police:Clone()
		guy = char
		char.Name = "StarterCharacter"
		wait()
		char.Parent = game.StarterPlayer
		player:LoadCharacter()
		guy:Destroy()
		for i,v in pairs(pack:GetChildren()) do
			local tool
			tool = v
			tool:Clone()
			tool.Parent = player.Backpack
		end
		print("Character loaded successfully")
	end
end)

So for one, after the players.PlayerAdded:Connect(function(player), add this:

player.CharacterAdded:Connect(function(character)

CharacterAutoLoads is off, wouldn’t it just return character with nil

I don’t think it should. It waits for the character to load essentially. But, if it’s off then it might. My bad. Let me re-look over the code. It’s weird how it stops working. Are there any errors in the output?

None, the whole script runs since “Character loaded successfully” is printed in the Output.

It clones the tool, correct? You’re able to see it?

Yes, I’m able to equip them however the scripts don’t run. They aren’t disabled, they just don’t work for some reason.

The scripts are located inside of the tool correct? You refer to the tool as “script.Parent”?

Yes, the scripts located inside the tool use script.Parent. However script.Parent isn’t defined as a variable inside of the scripts. Should I change that?

I mean, as long as you refer to the tool as script.Parent it should be ok. It would be smarter if you did like
“local tool = script.Parent”

I tried adding a variable for script.Parent. However, nothing changed.

So here’s a question, will the scripts work if you put it in your starterpack instead of cloning and parenting?

Yes, the scripts work perfectly fine when put into starterpack.

Darn, that is so weird. Am I able to by chance see your scripts for the tool? Try using print statements within your local/global scripts and see if anything is being printed.

I tried doing that and nothing gets printed. The main code is run in the local script which is powered by 1 big Tool.Equipped function. Could this possibly be something with filteringenabled or some other security thing?

So, if nothing is being printed when you do that, it’s probably some form of security thing. Try doing tool.Activated instead of Equipped. Then click and see if it runs when you have the tool equipped.

Also, maybe for your tool, set your HandleRequired property to false, sometimes that works?

I tried both of these, nothing changed. I tried disabling filteringenabled and still nothing changed.

Maybe change this to this?

v:Clone().Parent = player.Backpack

You didn’t put the tool clone in a variable so the clone wasn’t being set to the backpack ,but rather the original tool in the folder, maybe that’s the issue?

Also, the tools wont appear after a respawn, you have to also put it in your starterGear, so do this as well

v:Clone().Parent = player.Backpack