Error with the Player List

Hello!
I am having trouble with the Player List that I am doing.

Attempt 1 Code:

local ListUI = script.Parent.List
local SampleUI = script.Frame

local function clear()
	for _, clr in pairs(ListUI:GetChildren()) do
		if clr:IsA("Frame") then
			clr:Destroy()
		end
	end
end

local function fill()
	clear()
	for _, plr in pairs(game.Players:GetPlayers()) do
		if not ListUI:FindFirstChild(plr.Name) then
			local newUI = SampleUI:Clone()
			newUI.Name = plr.Name
			newUI.Username.Text = ""..plr.Name.." - "..plr:GetRoleInGroup(5320402)
			newUI.Parent = ListUI
		end
	end
	ListUI.CanvasPosition = UDim.new(0,0,0, ListUI.UI.AbsoluteContentSize.Y)
end
fill()


game.Players.PlayerAdded:Connect(function()
	fill()
end)

game.Players.PlayerRemoving:Connect(function()
	clear()
end)

Attempt 2 Code:

local ListUI = script.Parent.List
local SampleUI = script.Frame

local function clear()
	for _, clr in pairs(ListUI:GetChildren()) do
		if clr:IsA("Frame") then
			clr:Destroy()
		end
	end
end

local function fill()
	clear()
	for _, plr in pairs(game.Players:GetPlayers()) do
		if not ListUI:FindFirstChild(plr.Name) then
			local newUI = SampleUI:Clone()
			newUI.Name = plr.Name
			newUI.Username.Text = ""..plr.Name.." - "..plr:GetRoleInGroup(5320402)
			newUI.Parent = ListUI
		end
	end
	ListUI.CanvasPosition = UDim2.new(0,0,0, ListUI.UI.AbsoluteContentSize.Y)
end
fill()


game.Players.PlayerAdded:Connect(function()
	fill()
end)

game.Players.PlayerRemoving:Connect(function()
	clear()
end)

I get this error
erroc

[EDIT]
I pressed the Enter button.

What exactly is the problem your encountering?

I pressed the “Enter” Button, not on purpose.

So, I had to edit it.
30chiars

Replace CanvasPosition with CanvasSize

1 Like