center.BodyPosition.position=beacon.Center.Position teamColor=center.Color vel=center.BodyVelocity healerIsResting=false function restHealer()healerIsResting=true wait(5)healerIsResting=false end function joinTeam(M)local c=Instance.new("\067\111\108\111\114\051\086\097\108\117\101")c.Value=teamColor c.Name="\084\101\097\109"c.Parent=M M.Torso.Color=teamColor M.Torso.Reflectance=.2 M.LeftLeg.Color=teamColor M.LeftLeg.Reflectance=.2 M.RightLeg.Color=teamColor M.RightLeg.Reflectance=.2 end function onTouchHumanoid(M)local c=M:findFirstChild("\084\101\097\109",false)if c==nil then joinTeam(M)elseif c.Value~=teamColor then M.Health=0 return end if not healerIsResting then M.Health=M.Health+50 coroutine.resume(coroutine.create(restHealer))end end goingUp=false function goUp(M)if goingUp then return end goingUp=true vel.velocity=Vector3.new(0,M,0)wait(20/M)vel.velocity=Vector3.new(0,-2,0)goingUp=false end function onTouch(M)local c=M.Parent if c~=nill then local M=c:findFirstChild("\072\117\109\097\110\111\105\100",false)if M~=nill then onTouchHumanoid(M)goUp(10)return end end if M.Position.y>beacon.Center.Position.y then vel.velocity=Vector3.new(0,-2,0)goingUp=false elseif M.Position.y<beacon.Center.Position.y then goUp(2)end end function connectPart(M)M.Color=teamColor M.Touched:connect(onTouch)end

center.BodyPosition.position = beacon.Center.Position
teamColor = center.Color
vel = center.BodyVelocity

healerIsResting = false

function restHealer()
	healerIsResting = true
	wait(5)
	healerIsResting = false
end

function joinTeam(humanoid)
	local team = Instance.new("Color3Value")
	team.Value = teamColor
	team.Name = "Team"
	team.Parent = humanoid
	humanoid.Torso.Color = teamColor
	humanoid.Torso.Reflectance = 0.2
	humanoid.LeftLeg.Color = teamColor
	humanoid.LeftLeg.Reflectance = 0.2
	humanoid.RightLeg.Color = teamColor
	humanoid.RightLeg.Reflectance = 0.2
end

function onTouchHumanoid(humanoid)
	local team = humanoid:findFirstChild("Team", false)
	if team==nil then
		joinTeam(humanoid)
	elseif team.Value~=teamColor then
		-- Harm the enemy!
		humanoid.Health = 0
		return
	end
	
	if not healerIsResting then
		-- Heal the player
		humanoid.Health = humanoid.Health + 50
		coroutine.resume(coroutine.create(restHealer))
	end
end

goingUp = false
function goUp(speed)
	if goingUp then
		return
	end
	goingUp = true
	vel.velocity = Vector3.new(0,speed,0)
	wait(20/speed)
	vel.velocity = Vector3.new(0,-2,0)
	goingUp = false
end

function onTouch(touchedPart)
	-- see if a character touched it
	local parent = touchedPart.Parent
		if parent~=nill then
		local humanoid = parent:findFirstChild("Humanoid", false);
		if humanoid ~= nill then
			onTouchHumanoid(humanoid)
			goUp(10)
			return
		end
	end

	-- change direction
	if touchedPart.Position.y > beacon.Center.Position.y then
		vel.velocity = Vector3.new(0,-2,0)
		goingUp = false
	elseif touchedPart.Position.y < beacon.Center.Position.y then
		goUp(2)
	end
end

function connectPart(part)
	part.Color = teamColor
	part.Touched:connect(onTouch)
end
