Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can Some on help me with this clean up script?

Asked by 10 years ago

when i say clean up it don't work. can someone help me to fix it as i need to work for my tycoon as it all ways flooding with bricks.

function onChatted(msg, recipient, speaker)

    local source = string.lower(speaker.Name)
    msg = string.lower(msg)
--------------------------------------command between these bits--------------------------------------
    if (msg == "clean up") then
    cf = game.Workspace:GetChildren()
        for i = 1, #cf do
            if cf[i].Name == "TycoonBrick" then
                cf[i]:remove()
            elseif cf[i].Name == "UpgradedTycoonBrick" then
                cf[i]:remove()
            elseif cf[i].Name == "BestTycoonBrick" then
                cf[i]:remove()
            end 
        end

    end




--------------------------------------command between these bits--------------------------------------

end



function onPlayerEntered(newPlayer)
    newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end

game.Players.ChildAdded:connect(onPlayerEntered)


1 answer

Log in to vote
1
Answered by
SanityMan 239 Moderation Voter
10 years ago

Since I don't see you using recipient, I'm just going to rewrite your chatting functions.

game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg)
if msg:lower() == "clean up" then
for i,v in pairs(game.Workspace:GetChildren()) do --another for iterating loop
if v.Name == "TycoonBrick" or v.Name == "UpgradedTycoonBrick" or v.Name == "BestTycoonBrick" then
v:remove()
end
end
end
end)
end)

Should do what you want, tell me if it doesmt't. :)

Hope it helped!

0
thanks it help me out a lot mrpoliceman2004 20 — 10y
0
My pleasure! SanityMan 239 — 10y
Ad

Answer this question