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

How can i search the backpack of all clients for multiple and single tool(s)?

So my project has tools which can be bought only once by players, and hence is the need of searching all the clients for the tool. If the client has a tool, how can I make that client unique, like

local ToolOwner = client

something like that? And also, I need to check if the player has multiple tools in the same way. Can you please help me?

3 comments

0

Can't you loop through GetPlayers() and search through every player's backpack from the server?

0

By using a for iv in pairs loop get children

0

how to do that and also confirm the owner of tool, or parent of it?

1 answer

✓ Accepted answer
repeat wait(2) until game.Loaded
print("Game loaded.")
local Tool = "ToolNameHere"
local Owners = {}

wait(2)

for i,v in pairs(game.Players:GetChildren()) do
	if  v.Backpack:FindFirstChild(Tool) then
		-- they have the tool so we add them to the Owners table
		table.insert(Owners,i)
		print("Yes")
	else
		-- they dont have the tool so we make sure they arent on the table
		table.remove(Owners,i)
		print("No")
	end
end

Do keep in mind the rest of the code is up to you, best regards. ~DetectiveRaie

2 comments

0

its table.insert(Owners,v)

0

No, it is not! Do not run it like that it will not work.

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