Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I clone a tool to backpack of a player? (Read desc)

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

4 comments

0

i dont see any issues that would break the tool

0

Im going to make a video reporting the issue when i get home

0

Try using WaitForChild

0

Your weapon is the one missing the scripts.

1 answer

✓ Accepted answer

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)

4 comments

0

button.MouseButton1Down:Connect(function(player) <- with small b infront sorry for got to change that when i copyed it from my script. becourse the local i made has a small b 2

0

I just tried it, its not working. If it works for you, could you tell me where to place the tool name to determine if I did it wrong?

0

ur use the gui. my script is in the guiscreen and the button is also in the guiscreen so script.parent = guiscreen. tool i use replicatedstorage but u also can out it in workspace. game.(worspace or replicatedstorage).(other maps).tool

0

i see i made an error in this script. local tool = game.Workspace.WP.HK416 ..... local copy = tool:Clone() copy.Parent = Place

This discussion is preserved as it was. New answers, comments, and votes are closed.