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

Problem cloning the same tool twice?

Asked by 5 years ago
Edited 5 years ago

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
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. matiss112233 258 — 5y
0
Hi and thanks for your reply. No, that is not in the code it was just a side note for this forum. scagnetti619 24 — 5y
0
Have you tried doing `local tool = game.ReplicatedStorage["tool_one"]`? Because I don't see any errors. ChristianTRPOC 64 — 5y
0
The tool clones fine, it's just that every time you clone it overwrites the previous cloned tool scagnetti619 24 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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
Ad

Answer this question