Hello, so I’m making a pick up tool system using clickdetector but the player can grab the tool as many times as they can but I want the player to only get 1 item. In my case it’s a pickaxe
I’ve tried to fix it by looking at other DevForum topics but I don’t understand what they mean. I am new to scripting btw.
local clickdetector = script.Parent.ClickDetector
local StonePickaxe = game.ReplicatedStorage.StonePickaxe
clickdetector.MouseClick:Connect(function(player)
game.ReplicatedStorage.StonePickaxe:Clone().Parent = player.Backpack
if not player.Backpack:FindFirstChild("StonePickaxe") and not player.Character:FindFirstChild("StonePickaxe") then
end
end)```
Try putting this inside of the if statement. (Let me know if it worked.)
Where exactly should I put it? Should I delete the other stuff I did?
Like this:
if not player.Backpack:FindFirstChild("StonePickaxe") and not player.Character:FindFirstChild("StonePickaxe") then
game.ReplicatedStorage.StonePickaxe:Clone().Parent = player.Backpack
end
1 Like
It did not work. It still gives one more when I click it again
If that doesn’t work try this:
local clickdetector = script.Parent.ClickDetector
local StonePickaxe = game.ReplicatedStorage.StonePickaxe
clickdetector.MouseClick:Connect(function(player)
if player.Backpack:FindFirstChild("StonePickaxe") == nil and player.Character:FindFirstChild("StonePickaxe") == nil then
game.ReplicatedStorage.StonePickaxe:Clone().Parent = player.Backpack
end
end)```
3 Likes