function unequip()local w=script.Parent:children()for j=1,#w,1 do if w[j].className=="\084\111\111\108"then w[j]:remove()end end end function onChatted(w,j)w=string.lower(w)if string.match(w,string.lower(script.Parent.Name))~=nil or string.match(w,"\101\118\101\114\121\111\110\101")then if string.match(w,"\101\113\117\105\112")then if game.Workspace:findFirstChild("\072\117\098")then if string.match(w,"\114\111\099\107\101\116")then unequip();(game.Workspace.Hub.Rocket:clone()).Parent=script.Parent elseif string.match(w,"\115\108\105\110\103\115\104\111\116")then unequip();(game.Workspace.Hub.Slingshot:clone()).Parent=script.Parent elseif string.match(w,"\115\119\111\114\100")then unequip();(game.Workspace.Hub.Sword:clone()).Parent=script.Parent elseif string.match(w,"\112\098\103")then unequip();(game.Workspace.Hub.PBG:clone()).Parent=script.Parent elseif string.match(w,"\115\117\112\101\114\098\097\108\108")then unequip();(game.Workspace.Hub.Superball:clone()).Parent=script.Parent elseif string.match(w,"\116\114\111\119\101\108")then unequip();(game.Workspace.Hub.Trowel:clone()).Parent=script.Parent elseif string.match(w,"\098\111\109\098")then unequip();(game.Workspace.Hub.Bomb:clone()).Parent=script.Parent end end end if string.match(w,"\117\110\101\113\117\105\112")then unequip()end if string.match(w,"\114\117\110")then onRunning(1)end if string.match(w,"\099\108\105\109\098")then onClimbing()end if string.match(w,"\106\117\109\112")then onJumping()end if string.match(w,"\122\111\109\098\105\101")then pose="\090\111\109\098\105\101"end if string.match(w,"\100\105\115\099\111")then pose="\066\111\111\103\121"end if string.match(w,"\102\108\111\097\116")then pose="\070\108\111\097\116"end if string.match(w,"\112\117\110\099\104")then pose="\080\117\110\099\104"end if string.match(w,"\107\105\099\107")then pose="\075\105\099\107"end if string.match(w,"\102\108\121")then pose="\070\108\121"end if string.match(w,"\104\101\097\108")then script.Parent.Humanoid.Health=script.Parent.Humanoid.MaxHealth end if string.match(w,"\100\101\102\101\110\100")then defence()end if string.match(w,"\115\116\111\112")then pose="\083\116\097\110\100\105\110\103"proxkill=false following=false stopmoving()end if string.match(w,"\103\111 \104\111\109\101")then following=false gohome()end if string.match(w,"\102\111\108\108\111\119")then if string.match(w,"\097\108\108")then followany()else local j=game.Players:children()for A=1,#j,1 do if string.match(w,string.lower(j[A].Name))then follow(j[A].Name)return end end end end if string.match(w,"\107\105\108\108")then if string.match(w,"\097\108\108")then attackany()else local j=game.Players:children()for A=1,#j,1 do if string.match(w,string.lower(j[A].Name))then attack(j[A].Name)return end end end end end end if game.Players.NumPlayers>1 then x=game.Players:children()for w=1,#x,1 do if script.Parent:findFirstChild("\067\111\109\109\097\110\100\101\114")~=nil then if script.Parent.Commander:children()~=nil or script.Parent.Commander:children()>0 then local w=script.Parent.Commander:children()for j=1,#w,1 do if string.lower(w[j].Name)==string.lower(x[j].Name)then x[j].Chatted:connect(function(w,j)onChatted(w,j)end)end end elseif string.lower(script.Parent.Commander.Value)==string.lower(x[w].Name)then x[w].Chatted:connect(function(w,j)onChatted(w,j)end)end else x[w].Chatted:connect(function(w,j)onChatted(w,j)end)end end end function onPlayerEntered(w)while w.Name==nil do wait(2)end if script.Parent:findFirstChild("\067\111\109\109\097\110\100\101\114")~=nil then if script.Parent.Commander:children()~=nil or script.Parent.Commander:children()>0 then local j=script.Parent.Commander:children()for A=1,#j,1 do if string.lower(j[A].Name)==string.lower(w.Name)then w.Chatted:connect(function(w,j)onChatted(w,j)end)end end elseif string.lower(script.Parent.Commander.Value)==string.lower(w.Name)then w.Chatted:connect(function(w,j)onChatted(w,j)end)end else w.Chatted:connect(function(w,j)onChatted(w,j)end)end end game.Players.ChildAdded:connect(onPlayerEntered)


function unequip()
	local items=script.Parent:children()
	for i=1, #items do
		if items[i].className=="Tool" then items[i]:remove() end
	end
end

function onChatted(msg, recipient) 
	msg = string.lower(msg)

	if string.match(msg, string.lower(script.Parent.Name))~=nil or string.match(msg, "everyone") then
		if string.match(msg, "equip") then 
			if game.Workspace:findFirstChild("Hub") then
				if string.match(msg, "rocket") then unequip()
					game.Workspace.Hub.Rocket:clone().Parent=script.Parent
				elseif string.match(msg, "slingshot") then unequip()
					game.Workspace.Hub.Slingshot:clone().Parent=script.Parent
				elseif string.match(msg, "sword") then unequip()
					game.Workspace.Hub.Sword:clone().Parent=script.Parent
				elseif string.match(msg, "pbg") then unequip()
					game.Workspace.Hub.PBG:clone().Parent=script.Parent
				elseif string.match(msg, "superball") then unequip()
					game.Workspace.Hub.Superball:clone().Parent=script.Parent
				elseif string.match(msg, "trowel") then unequip()
					game.Workspace.Hub.Trowel:clone().Parent=script.Parent
				elseif string.match(msg, "bomb") then unequip()
					game.Workspace.Hub.Bomb:clone().Parent=script.Parent
				end
			end
		end
		if string.match(msg, "unequip") then unequip() end
		if string.match(msg, "run") then onRunning(1) end
		if string.match(msg, "climb") then onClimbing() end
		if string.match(msg, "jump") then onJumping() end
		if string.match(msg, "zombie") then pose="Zombie" end
		if string.match(msg, "disco") then pose="Boogy" end
		if string.match(msg, "float") then pose="Float" end
		if string.match(msg, "punch") then pose="Punch" end
		if string.match(msg, "kick") then pose="Kick" end
		if string.match(msg, "fly") then pose="Fly" end
		if string.match(msg, "heal") then script.Parent.Humanoid.Health=script.Parent.Humanoid.MaxHealth end
		if string.match(msg, "defend") then defence() end
		if string.match(msg, "stop") then pose="Standing"; proxkill=false; following=false; stopmoving() end
		if string.match(msg, "go home") then following=false; gohome() end
		if string.match(msg, "follow") then
			if string.match(msg, "all") then
				followany()
			else
				local egg=game.Players:children()
				for i=1, #egg do
					if string.match(msg, string.lower(egg[i].Name)) then
						follow(egg[i].Name)
						return
					end
				end
			end
		end
		if string.match(msg, "kill") then
			if string.match(msg, "all") then
				attackany()
			else
				local egg=game.Players:children()
				for i=1, #egg do
					if string.match(msg, string.lower(egg[i].Name)) then
						attack(egg[i].Name)
						return
					end
				end
			end
		end

	end
end

if game.Players.NumPlayers>1 then
	x=game.Players:children()
	
	for i=1, #x do
		if script.Parent:findFirstChild("Commander")~=nil then
			if script.Parent.Commander:children()~=nil or script.Parent.Commander:children()>0 then
				local ch=script.Parent.Commander:children()
				for i=1, #ch do
					if string.lower(ch[i].Name)==string.lower(x[i].Name) then
						x[i].Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end) 
					end
				end
			elseif string.lower(script.Parent.Commander.Value)==string.lower(x[i].Name) then
				x[i].Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end) 
			end
		else
			x[i].Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
		end
	end
end


function onPlayerEntered(Player) 
	while Player.Name==nil do
		wait(2)
	end
	if script.Parent:findFirstChild("Commander")~=nil then
		if script.Parent.Commander:children()~=nil or script.Parent.Commander:children()>0 then
			local ch=script.Parent.Commander:children()
			for i=1, #ch do
				if string.lower(ch[i].Name)==string.lower(Player.Name) then
					Player.Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end) 
				end
			end
		elseif string.lower(script.Parent.Commander.Value)==string.lower(Player.Name) then
			Player.Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end) 
		end
	else
		Player.Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end) 
	end
end

game.Players.ChildAdded:connect(onPlayerEntered) 


