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
if v.Name == "UFO" then
v:Destroy()
end
end
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.
2 comments
I tried this by using my stamper tool and spawning a UFO and the script didn't remove it. Any ideas why?
I put it into the developer console after I spawned the UFO's and then it removed the UFO's, I want it to remove as soon as it's in the game.