Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can Some on help me with this clean up script?

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

✓ Accepted answer

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!

2 comments

0

thanks it help me out a lot

0

My pleasure!

This discussion is preserved as it was. New answers, comments, and votes are closed.