How do I stop a click detector from giving more than one tool

Ok so I tried getting this part I click to clone a tool from server storage, it works but I don’t know how to make it so you can only get one tool from it and stop it from making multiple tools in your backpack :frowning:

Its a script inside the part in workspace

local Scroll = game:GetService("ServerStorage").Letter

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	local Letter = Scroll:Clone()
	Letter.Parent = player.Backpack
end)

heres a video

Simple fix, just add an if statement to check if the player’s backpack has a name called: Letter :stuck_out_tongue:

local Scroll = game:GetService("ServerStorage").Letter

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    if player.Backpack:FindFirstChild("Letter") == nil and player.Character:FindFirstChild("Letter") == nil then
       	local Letter = Tool:Clone()
	    Letter.Parent = player.Backpack
    end
end)
2 Likes

Wow thank you I’m still new to all this haha :slight_smile:

Not to worry! Everyone struggles all the time so it’s completely fine! The community does appreciate you making the time to create this post though :grinning_face_with_smiling_eyes:

1 Like

Can You Help Me with this one, i wanna do the same but at this one

local price = 6500 
local db = true
script.Parent.ClickDetector.MouseClick:Connect(function(player)
	if player.leaderstats.Money.Value >= price then  with your currency
		player.leaderstats.Money.Value = player.leaderstats.Money.Value - price  
		db = false
		game.ServerStorage["LMG"]:clone().Parent = player.Backpack 
		wait(10)
		db = true
	end
end)

Thanks

local Price = 6500
local DB = true
local Part = script.Parent
local ToolToDetect = "LMG" --This would be the Tool Name

Part.ClickDetector.MouseClick:Connect(function(Plr)
    local ToolCheck = game.ServerStorage:FindFirstChild(ToolToDetect)

    if ToolCheck == nil then
        warn("This tool is not currently in Server Storage!")
        return
    end

    local Backpack = Plr:WaitForChild("Backpack")
    local Char = Plr.Character
    local leaderstats = Plr:WaitForChild("leaderstats")
    local Money = leaderstats:WaitForChild("Money")

    if Backpack:FindFirstChild(ToolToDetect) or Char:FindFirstChild(ToolToDetect) then
        return
    end

    if Money.Value >= Price then
        DB = false

        Money.Value -= Price

        local ToolClone = ToolCheck:Clone()
        ToolClone.Parent = Backpack

        task.wait(10)
        DB = false
    end
end)