Before I press "Play", there are 3 things in workspace, Camera, Terrain, Baseplate. When I click play, there are 4 things because my character loads in. In the script below, after adding parts into the workspace after pressing "Play", when I click on the GUI button it prints "its cycling through workspace" 4 times. If I have an extra part in the workspace after clicking "Play", shouldn't it say that 5 times?
My problem is, I need the children to update whenever something is added into workspace during gameplay.
script.Parent.MouseButton1Click:Connect(function() w = workspace:GetChildren() for i,v in pairs(w) do print("its cycling through workspace") if v.Name == "Spray" then print("The if statement works") v:Destroy() end end end)
Try this tell me if it doesn't work
script.Parent.MouseButton1Click:Connect(function() for i,v in pairs(workspace:GetChildren()) do print("its cycling through workspace") if v.Name == "Spray" then print("The if statement works") v:Destroy() end end end)