I have a gui that will clone a tool into the player`s backpack when clicked, when the tool clones the tool will be missing scripts wich breaks the entire thing, anyone have a way to fix or rework my system?
-CODE
local player = game.Players.LocalPlayer -- Refer to the Player
local tool = game.Workspace.WP.HK416 -- Refer to the Tool
script.Parent.MouseButton1Down:connect(function() -- When it's clicked
if player:FindFirstChild("Backpack") then -- Not sure why I added this
tool:Clone().Parent = player.Backpack -- Clone the tool to their inventory
end -- End the if function
end) -- End the MouseButton1Down function
Video with problem: Video
or i have it like this
local PickAxe = Script.Parent `-- Asset ID of the image you want the to set the cursor to` local CursorId = "3190239131" `-- Create a ClickDetector` local ClickDetector = Instance.new("ClickDetector") ClickDetector.Parent = PickAxe ClickDetector.MaxActivationDistance = 15 ClickDetector.CursorIcon = "rbxassetid://"..CursorId -- Clicks on PickAxe with left mouse click -- player behind function is the player who clicks on it ClickDetector.MouseClick:Connect(function(player) -- player who clicked backpack local Place = player.Backpack -- make on other value and say that is the clone` local copy = PickAxe:Clone() -- Value.Parent is the place where is should copy or clone to the local place I made copy.Parent = Place end)
or like this in a gui like u do
local button = script.Parent.Button local tool = 'place tool' -- Clicks on button with left mouse click -- player behind function is the player who clicks on it Button.MouseButton1Down:Connect(function(player) -- player who clicked backpack local Place = player.Backpack -- make on other value and say that is the clone` local copy = PickAxe:Clone() -- Value.Parent is the place where is should copy or clone to the local place I made copy.Parent = Place end)