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

How do i scan the players inventory then place the item names on a label?

Im trying to make a admin gui and I want to be able to scan the players backpack then put the items in a frame with a few text labels.

1 answer

✓ Accepted answer

This isn't a request site, but I will give you a basic idea of what to do

You want to run through each child of their backpack and create a textlabel using a for loop

local plr=--plr
local frame=--where we put the textlabels

local equipped=false
if plr.Character:FindFirstChildOfClass("Tool") then
	local t=Instance.new("TextLabel")
	t.Position=UDim2.new(0,0,0,0)
	t.Text=plr.Character:FindFirstChildOfClass("Tool").Name
	t.Parent=frame
	
	equipped=true
end
for i,thing in pairs(plr.Backpack:GetChildren()) do
	local t=Instance.new("TextLabel")
	t.Position=UDim2.new(0,0,0,t.Size.Y.Offset*(i +(equipped and 1 or 0))
	t.Text=thing.Name
	t.Parent=frame
end

SO what did I do? I first set my variables and then checked if the player is holding a tool, if so I created a textlabel for that and set the equipped variable to true

I then went through every instance in their backpack and created a textlabel for that adjusting the position as i went along and accounted for that first textlabel if there was one.

You can remove this part and use one of roblox's automatic ui instances to do this for you.

2 comments

0

DanzLua, this wont work when i have more than one tool in my backpack... unless i just did somthing wrong

0

@deadwalker601 Can you check if it's a positioning problem and the textlabels are being parented correctly? (check how many textlabels there are)

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