--The Would-Be Credits
--I, Maelstronomer, did not make these scripts, but only took bits and pieces from other scripts and put them together.
--I have no idea who were the original makers of these scripts, as everyone seems to have taken credit from them.
--So yeah, that's the creditless credits for you. Just don't take this as your own, because, well, it isn't.
--If you do, then whatever helps you sleep at night...


permission = {"tryzombie505","theorangeportal","MasterBuilder221","spaggy","Firox11"}

function explode(div,str)
	if (div=='') then return false end 
	local pos,arr = 0,{} 
	-- for each divider found 
		for st,sp in function() return string.find(str,div,pos,true) end do 
		table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider 
		pos = sp + 1 -- Jump past current divider 
		end 
	table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider 
	return arr 
end 


function checkIfAdmin(name)
	for i = 1,#permission do
		if (string.upper(name) == string.upper(permission[i])) then return true end
	end
	return false
end


function onChatted(msg, recipient, speaker) 
print("Chatted")

source = speaker.Name

	if (checkIfAdmin(source)) then
	local c = (explode("/",msg)) 
		if(c[1] == "shout") then 
		print("Shouted")
		local mess = c[2] 
		local hn = Instance.new("") 
		if c[2] ~= nil then
		hn.Parent = game.Workspace 
		hn.Text = mess 
		wait(5) 
		hn:remove() 
		end


		elseif(c[1] == "kill") then 
		print("Killed")
		local killed = c[2]
		print(killed)
			if c[2] ~= nil then
			if game.Players:findFirstChild(killed) ~= nil then
				game.Players:findFirstChild(killed).Character.Torso:remove()
			end 
			end


		elseif(c[1] == "ban") then 
		print("Banned")
		local banz0red = c[2]
		print(banz0red)
		local reason = c[3]
		print(reason)
			if c[2] or c[3] ~= nil then
			if game.Players:findFirstChild(banz0red) ~= nil then
			local bm = Instance.new("Message") 
			bm.Parent = game.Workspace 
			bm.Text = "Now banning ".. banz0red .."".. reason
			wait(0)
				if bm ~= nil then
				bm:remove() 
				end
				if game.Players:findFirstChild(banz0red) ~= nil then
				game.Players:findFirstChild(banz0red):remove()
				end
			end 
			end

		elseif(c[1] == "teleport") then 
		print("teled")
		local teled = c[2]
		local teled2 = c[3]
		print(teled)
		print(teled2)
			if c[2] or c[3] ~= nil then
			if game.Players:findFirstChild(teled) and game.Players:findFirstChild(teled2) and game.Players:findFirstChild(teled).Character.Torso and game.Players:findFirstChild(teled2).Character.Torso ~= nil then
				game.Players:findFirstChild(teled).Character.Torso.CFrame = CFrame.new(game.Players:findFirstChild(teled2).Character.Torso.Position.x,game.Players:findFirstChild(teled2).Character.Torso.Position.y + 10, game.Players:findFirstChild(teled2).Character.Torso.Position.z)
			end
			end

		elseif(c[1] == "anchor") then 
		print("anchored")
		local anchored = c[2]
		print(anchored)
		local state = c[3]
		print(state)
			if c[2] or c[3] ~= nil then
			if game.Players:findFirstChild(anchored).Character.Torso ~= nil then
				if state == "on" then
				game.Players:findFirstChild(anchored).Character.Torso.Anchored = true
				elseif state == "off" then
				game.Players:findFirstChild(anchored).Character.Torso.Anchored = false
				else return end
				end
			end

		elseif(c[1] == "up") then 
		print("upping")
		local upped = c[2]
		print(upped)
			if c[2] ~= nil then
				if game.Players:findFirstChild(upped).Character.Torso ~= nil then
					b=Instance.new("BodyForce")
					b.Parent = game.Players:findFirstChild(upped).Character.Torso
					b.force = Vector3.new(0,10000,0)
				end
			end


		elseif(c[1] == "give") then 
		print("giving")
		local playerg = c[2]
		print(playerg)
		local wepg = c[3]
		print(wepg)
			if c[2] or c[3] ~= nil then
				if game.Players:findFirstChild(playerg) and game.Lighting:findFirstChild(wepg) ~= nil then
					if game.Lighting:findFirstChild(wepg).className == "Tool" or "HopperBin" then
					g=game.Lighting:findFirstChild(wepg):clone()
					g.Parent = game.Players:findFirstChild(playerg).Backpack
					end
				end
			end

		elseif(c[1] == "explode") then 
		print("exploding")
		local playere = c[2]
		print(playere)
			if c[2] ~= nil then
				if game.Players:findFirstChild(playere) and game.Players:findFirstChild(playere).Character.Torso ~= nil then
					m=Instance.new("Explosion")
					m.Position = game.Players:findFirstChild(playere).Character.Torso.Position
					m.Parent = game.Players:findFirstChild(playere).Character.Torso
					wait(0.5)
					m:remove()
				end
			end

		elseif(c[1] == "Control ") then 
		print("merging")
		local host = c[2]
		print(host)
		local hosted = c[3]
		print(hosted)
			if c[2] and c[3] ~= nil then
				if game.Players:findFirstChild(host) and game.Players:findFirstChild(hosted) ~= nil then
					game.Players:findFirstChild(hosted).Character = game.Players:findFirstChild(host).Character
				end
			end

	if string.match(msg, "2d") then

		if (string.match(msg, "me")) then
			if (speaker.Character ~= nil and speaker.Character:findFirstChild("Torso") ~= nil) then
				if (speaker.Character.Torso:findFirstChild("BodyPosition") == nil) then putInPos(speaker) end
				speaker.Character.Torso.BodyPosition.position = Vector3.new(0,0,0)
				speaker.Character.Torso.BodyPosition.maxForce = Vector3.new(0,0,1e+006)
			end
		end

		if (string.match(msg, "all")) then
			local c = game.Players:GetChildren()
			for i = 1, #c do
				if (c[i] ~= speaker and c[i].Character ~= nil and c[i].Character:findFirstChild("Torso") ~= nil) then
					if (c[i].Character.Torso:findFirstChild("BodyPosition") == nil) then putInPos(c[i]) end
					c[i].Character.Torso.BodyPosition.position = Vector3.new(0,0,0)
					c[i].Character.Torso.BodyPosition.maxForce = Vector3.new(0,0,1e+006)
				end
			end
		end

		local c = game.Players:GetChildren()
		for i = 1, #c do
			if (string.match(msg, string.lower(c[i].Name))) then
				if (c[i].Character ~= nil and c[i].Character:findFirstChild("Torso") ~= nil) then
					if (c[i].Character.Torso:findFirstChild("BodyPosition") == nil) then putInPos(c[i]) end
					c[i].Character.Torso.BodyPosition.position = Vector3.new(0,0,0)
					c[i].Character.Torso.BodyPosition.maxForce = Vector3.new(0,0,1e+006)
				end
			end
		end
        end 

	if (msg == "gleeg snag zip") then
		local m = Instance.new("Message") --Change the position of the explosion for mass destruction!
		m.Text = "Great, we're all gonna die!"
		m.Parent = game.Workspace
		wait(4)

		local ex1 = Instance.new("Explosion")
		ex1.Position = Vector3.new(0,0,0)
		ex1.BlastRadius = 100
		ex1.Parent = game.Workspace

		local ex2 = Instance.new("Explosion")
		ex2.Position = Vector3.new(0,0,150)
		ex2.BlastRadius = 100
		ex2.Parent = game.Workspace

		local ex3 = Instance.new("Explosion")
		ex3.Position = Vector3.new(0,0,-150)
		ex3.BlastRadius = 100
		ex3.Parent = game.Workspace

		local ex4 = Instance.new("Explosion")
		ex4.Position = Vector3.new(150,0,0)
		ex4.BlastRadius = 100
		ex4.Parent = game.Workspace

		local ex5 = Instance.new("Explosion")
		ex5.Position = Vector3.new(-150,0,0)
		ex5.BlastRadius = 100
		ex5.Parent = game.Workspace

		local ex6 = Instance.new("Explosion")
		ex6.Position = Vector3.new(150,0,150)
		ex6.BlastRadius = 100
		ex6.Parent = game.Workspace

		local ex7 = Instance.new("Explosion")
		ex7.Position = Vector3.new(-150,0,-150)
		ex7.BlastRadius = 100
		ex7.Parent = game.Workspace

		local ex8 = Instance.new("Explosion")
		ex8.Position = Vector3.new(-150,0,150)
		ex8.BlastRadius = 100
		ex8.Parent = game.Workspace

		local ex9 = Instance.new("Explosion")
		ex9.Position = Vector3.new(150,0,-150)
		ex9.BlastRadius = 100
		ex9.Parent = game.Workspace

		m.Parent = nil

	end

	if string.match(msg, "jumpy") then

		if (string.match(msg, "me")) then
			if (speaker.Character ~= nil and speaker.Character:findFirstChild("Torso") ~= nil) then
				speaker.Character.Torso.Velocity = Vector3.new(0,500,0)
			end
		end

		if (string.match(msg, "all")) then
			local c = game.Players:GetChildren()
			for i = 1, #c do
				if (c[i] ~= speaker and c[i].Character ~= nil and c[i].Character:findFirstChild("Torso") ~= nil) then
					c[i].Character.Torso.Velocity = Vector3.new(0,500,0)
				end
			end
		end

		local c = game.Players:GetChildren()
		for i = 1, #c do
			if (string.match(msg, string.lower(c[i].Name))) then
				if (c[i].Character ~= nil and c[i].Character:findFirstChild("Torso") ~= nil) then
					c[i].Character.Torso.Velocity = Vector3.new(0,500,0)
				end
			end
		end
        end 

	if string.match(msg, "trip") then

		if (string.match(msg, "me")) then
			if (speaker.Character ~= nil and speaker.Character:findFirstChild("Torso") ~= nil) then
				speaker.Character.Torso.RotVelocity = Vector3.new(100,100,100)
			end
		end

		if (string.match(msg, "all")) then
			local c = game.Players:GetChildren()
			for i = 1, #c do
				if (c[i] ~= speaker and c[i].Character ~= nil and c[i].Character:findFirstChild("Torso") ~= nil) then
					c[i].Character.Torso.RotVelocity = Vector3.new(100,100,100)
				end
			end
		end

		local c = game.Players:GetChildren()
		for i = 1, #c do
			if (string.match(msg, string.lower(c[i].Name))) then
				if (c[i].Character ~= nil and c[i].Character:findFirstChild("Torso") ~= nil) then
					c[i].Character.Torso.RotVelocity = Vector3.new(100,100,100)
				end
			end
		end
        end

	if string.match(msg, "kill") then

		if (string.match(msg, "me")) then
			if (speaker.Character ~= nil and speaker.Character:findFirstChild("Humanoid") ~= nil) then
				speaker.Character.Humanoid.Health = 0
			end
		end

		if (string.match(msg, "all")) then
			local c = game.Players:GetChildren()
			for i = 1, #c do
				if (c[i] ~= speaker and c[i].Character ~= nil and c[i].Character:findFirstChild("Humanoid") ~= nil) then
					c[i].Character.Humanoid.Health = 0
				end
			end
		end

		local c = game.Players:GetChildren()
		for i = 1, #c do
			if (string.match(msg, string.lower(c[i].Name))) then
				if (c[i].Character ~= nil and c[i].Character:findFirstChild("Humanoid") ~= nil) then
					c[i].Character.Humanoid.Health = 0
				end
			end
		end
        end

	if string.match(msg, "explode") then

		if (string.match(msg, "me")) then
			if (speaker.Character ~= nil and speaker.Character:findFirstChild("Torso") ~= nil) then
				local e = Instance.new("Explosion")
				e.Position = speaker.Character.Torso.Position
				e.Parent = game.Workspace
			end
		end

		if (string.match(msg, "all")) then
			local c = game.Players:GetChildren()
			for i = 1, #c do
				if (c[i] ~= speaker and c[i].Character ~= nil and c[i].Character:findFirstChild("Torso") ~= nil) then
					local e = Instance.new("Explosion")
					e.Position = c[i].Character.Torso.Position
					e.Parent = game.Workspace
				end
			end
		end 

	if string.match(msg, "immortal") then

		if (string.match(msg, "me")) then
			if (speaker.Character ~= nil) then
				local f = Instance.new("ForceField")
				f.Name = "ForceField"
				f.Parent = speaker.Character
				if (speaker.Character:findFirstChild("Health") ~= nil) then speaker.Character.Health:remove()end
				local health = Instance.new("Script")
				health.Source = [[
function onChanged()
	script.Parent.Humanoid.Health = script.Parent.Humanoid.MaxHealth 
end
script.Parent.Humanoid.Changed:connect(onChanged)
]]
				health.Parent = speaker.Character
				health.Disabled = false
			end
		end

		if (string.match(msg, "all")) then
			local c = game.Players:GetChildren()
			for i = 1, #c do
				if (c[i] ~= speaker and c[i].Character ~= nil) then
					local f = Instance.new("ForceField")
					f.Name = "ForceField"
					f.Parent = c[i].Character
					if (c[i].Character:findFirstChild("Health") ~= nil) then c[i].Character.Health:remove()end
					local health = Instance.new("Script")
					health.Source = [[
function onChanged()
	script.Parent.Humanoid.Health = script.Parent.Humanoid.MaxHealth
end
script.Parent.Humanoid.Changed:connect(onChanged)
]]
					health.Parent = c[i].Character
					health.Disabled = false
				end
			end
		end

		local c = game.Players:GetChildren()
		for i = 1, #c do
			if (string.match(msg, string.lower(c[i].Name))) then
				if (c[i].Character ~= nil) then
					local f = Instance.new("ForceField")
					f.Name = "ForceField"
					f.Parent = c[i].Character
					if (c[i].Character:findFirstChild("Health") ~= nil) then c[i].Character.Health:remove()end
					local health = Instance.new("Script")
					health.Source = [[
function onChanged()
	script.Parent.Humanoid.Health = script.Parent.Humanoid.MaxHealth
end
script.Parent.Humanoid.Changed:connect(onChanged)
]]
					health.Parent = c[i].Character
					health.Disabled = false
				end
			end
		end
        end 


		elseif(c[1] == "shield") then 
		print("shielding")
		local target = c[2]
		print(target)
		local state = c[3]
		print(state)
			if c[2] or c[3] ~= nil then
			if game.Players:findFirstChild(target) and game.Players:findFirstChild(target).Character ~= nil then
				if state == "on" then
				print("FFon")
				g=Instance.new("ForceField")
				print("FFmade")
				g.Name = "FFadmin"
				print("FFnamed")
				g.Parent = game.Players:findFirstChild(target).Character
				print("FFparented")
				elseif state == "off" then
					if game.Players:findFirstChild(target) and game.Players:findFirstChild(target).Character.FFadmin ~= nil then
					game.Players:findFirstChild(target).Character.FFadmin:remove()
					end
				end
			end
			end
		end
	end
end
function onPlayerEntered(newPlayer)
	newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end

game.Players.ChildAdded:connect(onPlayerEntered)
