Hello! I have a whiteboard that I can paint on, which creates separate ImageLabels which can have different colours. However, I also have a clear button in SurfaceGui, which is supposed to clear all the ImageLabels from the board when it is clicked. It however, doesn’t work:
local children = script.Parent.Parent.Parent.Parent.SurfaceGui.Frame.Container:GetChildren()
script.Parent.MouseButton1Click:Connect(function()
for i = 1, #children do
children[i]:Destroy()
end
end)
script.Parent.MouseButton1Click:Connect(function()
local children = script.Parent.Parent.Parent.Parent.SurfaceGui.Frame.Container
for i, v in ipairs(children:GetChildren()) do
v:Destroy()
end
end)
local children = script.Parent.Parent.Parent.SurfaceGui.Frame.Container:GetChildren()
script.Parent.MouseButton1Click:Connect(function()
for paint, children in pairs(children) do
children:Destroy()
wait()
end
end)
The imagelabels are created inside the model, so would I have to change :GetChildren() if the script is in ServerScriptService? The script is currently in the textbutton of the clear button at the moment.
Server script service only executes arguments throughout the server. Since you already created the children variable, it must be inside of the model of the paint