How would I loop this script so it always runs? Basically, every time it finds something named "UFO" inside workspace, it will be removed.
game.Workspace.ChildAdded:connect(function(child) if child.Name == "UFO" then child:Destroy() end end)
That'll be fine. Just stick a for loop after it to get rid of any existing UFO things.
for k,v in pairs(game.Workspace:GetChildren()) do if v.Name == 'UFO' then v:Destroy(); end; end;
You don't need to loop through it every time a Child is added, because the only change will be the new Child - Which will be removed by your existing code.
In order to do this we can use a for loop.
http://wiki.roblox.com/index.php?title=Loops
For everything the loop finds, it will do something. The code would look something like
game.Workspace.ChildAdded:connect(function(child) for int,v in pairs(game.Workspace:GetChildren()) do --iterates through the workspace and its children if v.Name == "UFO" then --checks if the current item it's checking is named ufo v:Destroy() end end --then it loops until it does it for everything end)
in a for loop, int represents the integer (the number) that the loop is at. so if there's 3 children in Workspace int will get up to 3. v represents the current item that it's checking.
Hope that helped.