I was browsing through the free models and found this:
voted = {2}
function getVoted(name)
if voted == {2} then return false end
for i=2,#voted do
if voted[i] == name then
return true
end
end
return false
end
function onChatted(msg, recipient, speaker)
source = speaker.Name
msg = string.lower(msg)
if ((msg == "cleanup") or (msg == "clean up")) then
if getVoted(source) == false then
table.insert(voted, source)
if #voted > (game.Players.NumPlayers * 0.7) then
local bricks = game.Workspace:getChildren()
for i=1,#bricks do
if (bricks[i].Name == "Part") then
bricks[i]:remove()
end
end
voted = {2}
end
end
end
end
function onPlayerEntered(newPlayer)
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
end
game.Players.ChildAdded:connect(onPlayerEntered)
Problems:
1) From what I can see, it deletes "Part". But the building blocks I used aren't "Part". Some are named smooth block model, or seat. How do I make it delete anything, without deleting scripts or groups?
2) It says "getChildren()" does this function look inside groups? Because, I've gathered when you copy something, it plops it straight into "Workplace", which is great, because I want the clean up script to wipe out anything inside work place, without damaging scripts or groups inside.
Thanks. |