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

Problem cloning the same tool twice?

Hi there! My issue is as follows:

The user clicks a button and the end result is a selected tool appears that they can then pick up. They can do this as many times as they wish. The problem is if they select the same tool twice, when the second tool is cloned it will actually remove the first tool form the players backpack.

So they select a tool, it appears then they pick it up. They select the same tool again and it appears, however the second it appears... the one it the backpack is removed (before they pick it up). So the problem is there can be only one tool at a time.

I need them to be able to make as many clones (tools) as needed without removing the original clone.

Parent issue?

Here is a sample of the script... any hints in the right direction would be great!!

local tool = game.ReplicatedStorage.tool_one   (have also tried ServerStorage)
local toolclone = tool:Clone()
local Storage = script.Parent.Parent.Parent:WaitForChild("Storage") 
(side note: storage is in workspace, no this is not in the code ;)
--------------------------

toolclone:Clone()
toolclone.Handle.CFrame = script.Parent.CloneBox.CFrame - Vector3.new(0,1.4,0)
toolclone.Parent = Storage

4 comments

0

Is this copy+pasted from your script? if so, where you put ":WaitForChild("Storage") <<< this is in workspace" is incorrect, because you either use "--" or "[-- --]" for commenting on lua. I hope this fixes it because I don't see any other major issues.

0

Hi and thanks for your reply. No, that is not in the code it was just a side note for this forum.

0

Have you tried doing local tool = game.ReplicatedStorage["tool_one"]? Because I don't see any errors.

0

The tool clones fine, it's just that every time you clone it overwrites the previous cloned tool

1 answer

This might work Try it. I cant test it myself because i do not know what your workspace is set up like. Hope this helps. If the question is answered mark the question as answered.





	local tool = game.ReplicatedStorage.tool_one   (have also tried ServerStorage)
	local toolclone = tool:Clone()
	local Storage = script.Parent.Parent.Parent:WaitForChild("Storage")
	(side note: storage is in workspace, no this is not in the code ;)
	--------------------------
	 
	local Tool_one = toolclone:Clone()
	Tool_one.Parent = game.Players.LocalPlayer.backpack

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