Cloning problem

Hello.
I made a simple shooting game and a menu for gun selection.
testing2 - Roblox Studio (gyazo.com)
As you can see above(the video) it works fine.

But the problem occurs when I make it so that when you click on a gun from the selection menu , you get the gun but the when pressed the gun does not do anything.

Cloning script (Edit)

local function onclicked()
	local copy = game.ReplicatedStorage:WaitForChild(script.Parent.Name):Clone() -- In this case script.Parent.Name refers to Laser
	for _ ,v in pairs(game.Players.LocalPlayer:WaitForChild("Backpack"):GetChildren()) do
		v:Destroy()
	end
	copy.Parent = game.Players.LocalPlayer:WaitForChild("Backpack")
end

script.Parent.MouseButton1Click:Connect(onclicked)

selection menu -

In the selection menu I made it so that when clicked on the picture of a certain gun that gun clones into your backpack from Replicated Storage(I could have done Server storage but I was lazy to setup remote event) and any other gun in your backpack gets destroyed.
When I click on a zombie with the cloned gun it does nothing and nothing fires(I tested using prints).
What is the problem when cloning, do the events make no connection with the parent?

Can I see your scripts? Without them I cannot help.

local function onclicked()
	local copy = game.ReplicatedStorage:WaitForChild(script.Parent.Name):Clone() -- In this case script.Parent.Name refers to Laser
	for _ ,v in pairs(game.Players.LocalPlayer:WaitForChild("Backpack"):GetChildren()) do
		v:Destroy()
	end
	copy.Parent = game.Players.LocalPlayer:WaitForChild("Backpack")
end

script.Parent.MouseButton1Click:Connect(onclicked)

Can I see the script in one of the guns?

I am pretty sure that the script in guns is not related to this topic and won’t be required in order to solve this.
As I said when I don’t clone them they work fine (the original version works fine).
But the cloned version from R.S does not seem to work.

Try adding to the player’s Backpack on the server side.
(You can first try it manually in Studio)

You should’ve since otherwise the tool is being cloned on local side and on server one there is nothing in player’s backpack and thats why erver scripts in tool dont work

1 Like

Thanks to @Club_Moo for the solution , and @primo222 thank you for explaining it to me.