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)
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?
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)
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.
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