For some reason this :GetChildren() does not work:

When I was trying to get the children of the scroll frame to destroy them :GetChildren wont work can I have help.

Workspace:
image

 20:53:32.109  Players.richithebest123.PlayerGui.ModGui.Main.ScrollingFrame.LocalScript:31: attempt to index nil with 'GetChildren'  -  Studio


while wait(5) do
	for i, v in pairs(game.Players:GetPlayers()) do
		updatelist(v)
	end
	
	for i, v in pairs(script.Parent:GetChildren()) do
		v:Destroy()
	end
end

Where is the LocalScript exactly from where you’re wanting to remove the Children of the ScrollingFrame?

It’s in the scrolling frame so like some here image

It would be destroying it self in the process then… because its a child of it

in the updatelist it has a check function to see if the thing the script is destroying

Are you sure you’re implementing a sanity check? Cause it really looks like the script is being destroyed from this view of perspective

here is the code then:

--// Varibles \\--

local remotes = game.ReplicatedStorage:WaitForChild("AdminRemote")

local template = script.Template

local buttonconnections = {}

local playerName = script.Parent.Parent.PlayerTextBox

--// Functions \\--

local function updatelist(plr)
	
	local new = template:Clone()
	new.Text = plr.Name
	new.Name = plr.Name
	new.Parent = script.Parent
	
	buttonconnections[#buttonconnections + 1] = new.MouseButton1Click:Connect(function()
		playerName.Text = new.Name
	end)
end

--// While Loop \\--

while wait(5) do
	for i, v in pairs(game.Players:GetPlayers()) do
		updatelist(v)
	end
	
	for i, v in pairs(script.Parent:GetChildren()) do
		v:Destroy()
	end
end

Maybe the scrolling frame is being deleted somewhere so it cant find the children

Edit: this was before i saw the code above me

nvm I delted it by accident lol

Why not just do script.Parent:ClearAllChildren()

I just found the issue :man_facepalming: You have the code in a while loop, so the first time it goes through it deletes it, and then the second time it goes around the loop it has nothing to get children off, so it displays the error

Next time I would suggest using ClearAllChildren method instead of a for loop (unless you want to delete only specific children of an instance with an if statement for example)