When I was trying to get the children of the scroll frame to destroy them :GetChildren wont work can I have help.
Workspace:
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
--// 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
I just found the issue 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)