I made a script (Local) to count all workspace objects and make it into a GUI list but I only get my players's name? What I tried: (Line 15-23 is what I need help with)

local nGiven = "HGround"
script.Parent:WaitForChild("Example").Visible = false
while true do wait()
	print("Loop")
	local del = script.Parent:GetChildren()
	for i=1,#del do
		if del[i].Name == nGiven then
			del[i]:Remove()
		end
	end
		--delete --
	local buttonY  = script.Parent:WaitForChild("Example").Size.Y
	local lastPlrPOS = UDim2.new(0,0,0,0) - UDim2.new(0,0,buttonY,0)
	local workspacE = game.Workspace:GetChildren()
	for i=1, #workspacE do
		local D = script.Parent:WaitForChild("Example"):Clone()
		D.Position = UDim2.new(lastPlrPOS) + UDim2.new(0,0,buttonY,0)
		lastPlrPOS = UDim2.new(lastPlrPOS) + UDim2.new(0,0,buttonY,0)
		D.Text = workspacE[i].Name
		D.Name = nGiven
		D.Parent = script.Parent
		D.Visible = true
	end
end

Explorer: Click here Gui when I run: Click here

Help?

5 comments

0

You should do local preDel = script.Parent:GetChildren() and then do local del = #preDel, and that will be the number of objects in workspace.

0

I made edits to the line before the actual code. (Line 15-23 is what I need help with)

0

dose game.Workspace:GetChildren() return a player name instead of a table or does the table's contents have the player name inside of it?

0

If you want to get the number of items in a table, what :GetChildren() returns, you would use # before the line. So #game.Workspace:GetChildren() would print the number of objects in workspace.

0

It prints 4, the number is correct, there is 4 items in workspace. And I don't know if it returns a player name or table.