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 every time a player clicks a part?

I've already made it so when a player clicks on a part they get a tool, but I want to make it so every time they click the part they get the same tool. Right now you can only click on it once and afterwards you can't click to get the tool anymore.

local dirt = script.Parent
local bagOfDirt = game.ReplicatedStorage["Bag of Dirt"]
local decal = dirt.dirty.Decal



dirt.ClickDetector.MouseClick:Connect(function(hit)
	if hit then
		bagOfDirt:Clone()
		bagOfDirt.Parent = hit.Backpack
	end
end)

1 comment

0

can you post the code so i can see what method you're using?

2 answers

✓ Accepted answer

i see the issue, you're cloning the bag of dirt but not doing anything with the clone, so you're just taking the tool, instead, add a variable to the clone to make it work correctly

local dirt = script.Parent 
local bagOfDirt = game.ReplicatedStorage["Bag of Dirt"] 
local decal = dirt.dirty.Decal 
dirt.ClickDetector.MouseClick:Connect(function(hit) 
	if hit then 
		local tool = bagOfDirt:Clone() 
		tool.Parent = hit.Backpack 
	end 
end)

I figured it out, haha. I was making the actual dirt bag tool go from replicated storage to the player and not the clone, so it would only work once.

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