Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Lock a specfic tool?

So this script locks all the tools in the players inventory, and I would like it to be able to lock only one tool which is called football?

game:GetService("Players").PlayerAdded:connect(function(player)
 local function hookTool(tool)
  if not tool:IsA("Tool") then return end
  game:GetService("RunService").Heartbeat:wait()
  tool.Parent = player.Character
 end
 
 player:WaitForChild("Backpack").ChildAdded:connect(hookTool)
 
 player.ChildAdded:connect(function(child)
  if child:IsA("Backpack") then
   child.ChildAdded:connect(hookTool)
  end
 end)
 
 for i,v in pairs(player.Backpack:GetChildren()) do
  hookTool(v)
 end
end)

1 answer

Hello. Just use an if statement checking if the tool's game is football in the for loop looping through the backpack. Try this:

game:GetService("Players").PlayerAdded:connect(function(player)
	local function hookTool(tool)

		if not tool:IsA("Tool") then return end

		game:GetService("RunService").Heartbeat:wait()
		tool.Parent = player.Character
	end

	player:WaitForChild("Backpack").ChildAdded:connect(hookTool)

	player.ChildAdded:connect(function(child)
		if child:IsA("Backpack") then
			child.ChildAdded:connect(hookTool)
		end
	end)

	for i, v in pairs(player.Backpack:GetChildren()) do
		if v.Name == "football" then
			hookTool(v)
		end
	end
end)

Please upvote and accept this answer if it helps.

3 comments

0

which section do I put it in?

0

I gave you the script. Just copy and paste it.

0

I did but the football didn't drop and it locked all the gears in my inventory

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