Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

0
i dont see any issues that would break the tool Gameplayer365247v2 1055 — 5y
0
Im going to make a video reporting the issue when i get home dizzycutepuppy56 -4 — 5y
0
Try using WaitForChild Igoralexeymarengobr 365 — 5y
0
Your weapon is the one missing the scripts. save_database 15 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
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 User#27824 0 — 5y
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? dizzycutepuppy56 -4 — 5y
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 User#27824 0 — 5y
0
i see i made an error in this script. local tool = game.Workspace.WP.HK416 ..... local copy = tool:Clone() copy.Parent = Place User#27824 0 — 5y
Ad

Answer this question