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

Asked by 3 years ago
Edited 3 years ago

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)
0
can you post the code so i can see what method you're using? Stea_my 48 — 3y

2 answers

Log in to vote
0
Answered by
Stea_my 48
3 years ago

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)
Ad
Log in to vote
0
Answered by 3 years ago

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.

Answer this question