Need Help On My Tool Giver

So Im Making a Game Today And I Decided To Make a Tool Giver, But I Have a Question, How Do I Make It So The Player Can Only Take 1 Tool Each Life ?
If You Have a Solution To This Problem Please Reply

Code :

image

You can try this:

local ToolNames = {"[Revolver]"}
local Storage = game:GetService("ServerStorage")

local Part = script.Parent
local ClickDetector = Part:WaitForChild("ClickDetector")

ClickDetector.MouseClick:Connect(function(Player)
	if Player and Player.Character then
		local Backpack = Player:WaitForChild("Backpack")
		for i = 1, #ToolNames do
			local Tool = Storage:FindFirstChild(ToolNames[i])
			if Tool and Backpack:FindFirstChild(ToolNames[i]) == nil then
				Tool:Clone().Parent = Backpack
			end
		end
	end
end)
1 Like
local Storage = game:GetService("ServerStorage")
local ToolNames = {"Revolver"}

local Part = script.Parent
local Click = Part.ClickDetector

Click.MouseClick:Connect(function(Player)
	local Backpack = Player.Backpack
	local Character = Player.Character
	for _, ToolName in ipairs(ToolNames) do
		local BackpackTool = Backpack:FindFirstChild(ToolName)
		local CharacterTool = Character:FindFirstChild(ToolName)
		if not (BackpackTool or CharacterTool) then
			local Tool = Storage:FindFirstChild(ToolName)
			if Tool then
				local ToolClone = Tool:Clone()
				ToolClone.Parent = Backpack
			end
		end
	end
end)

The character could have the tool equipped.

local hastool = Player.Backpack:FindFirstChildWhichIsA("Tool") or Player.Character:FindFirstChildWhichIsA("Tool")
if not hastool then
-- code here
end

If character have equipped tool, then he cant click on click detector.

https://gyazo.com/a4fe7a08715f901c81f7ac81a7858a46

local click = script.Parent

click.MouseClick:Connect(function(player)
	print("Clicked!")
end)

Add a handle to the tool. (ignore this)

Not all tools require a handle.

https://developer.roblox.com/en-us/api-reference/property/Tool/RequiresHandle

Thank You So Much! It Works Pretty Well