TurnJump=1.0 TurnSpeed=.0001 SpeedVariation=1 Beam=script.Parent.Tilt.H1 CPan=0 CTilt=0 local G=Instance.new("\087\101\108\100")G.Part0=script.Parent.Base G.Part1=script.Parent.Pan.Handle G.C1=CFrame.fromEulerAnglesXYZ(0,0,0)*CFrame.new(0,1,0)G.Parent=script.Parent local E=Instance.new("\087\101\108\100")E.Part0=script.Parent.Pan.Center E.Part1=script.Parent.Tilt.Handle E.C1=CFrame.fromEulerAnglesXYZ(math.pi/-2,math.pi/2,0)*CFrame.new(0,0,0)E.Parent=script.Parent OneDegree=math.pi/180 function Degrees(G)return G*OneDegree end Colors={"\072\111\116 \112\105\110\107","\082\101\097\108\108\121 \098\108\117\101"}function RandColor()return Colors[math.random(1,#Colors)]end function On(G)Beam.BrickColor=BrickColor.new(G)Beam.Transparency=.3 end function Off()Beam.Transparency=1 end function Reach(x,S,w)ReachedPan=false ReachedTilt=false Moving=true Current=CPan Pos=0 while Current~=x do Current=Current+TurnJump Pos=Pos+1 if Current>359 then Current=Current-360 end end Current=CPan Neg=0 while Current~=x do Current=Current-TurnJump Neg=Neg+1 if Current<0 then Current=Current+360 end end Rand=math.random(1,2)while ReachedPan==false or ReachedTilt==false and Moving==true do if CPan-.5<x and CPan+.5>x then ReachedPan=true end if CTilt-.5<S and CTilt+.5>S then ReachedTilt=true end if ReachedPan==false then PN=0 if Pos<Neg then PN=1 elseif Neg<Pos then PN=-1 elseif Neg==Pos then if Rand==1 then PN=-1 else PN=1 end end CPan=CPan+TurnJump*PN if CPan>359 then CPan=CPan-360 end if CPan<0 then CPan=360+CPan end G.C1=G.C1*CFrame.fromEulerAnglesXYZ(0,(Degrees(1)*PN)*TurnJump,0)end if ReachedTilt==false then PN=0 if S-CTilt<0 then PN=-1 elseif S-CTilt>=0 then PN=1 end CTilt=CTilt+PN*TurnJump E.C1=E.C1*CFrame.fromEulerAnglesXYZ(0,(Degrees(1)*PN)*TurnJump,0)end wait(w)end end function Move()Moving=false wait(script.Parent.Move.Value.Z*2)Reach(script.Parent.Move.Value.X,script.Parent.Move.Value.Y,script.Parent.Move.Value.Z)end script.Parent.Move.Changed:connect(Move)while true do On(RandColor())Reach(math.random(0,159),math.random(-115,115),TurnSpeed+math.random((TurnSpeed*-SpeedVariation)*1000000,(TurnSpeed*SpeedVariation)*1000000)/1000000)end


TurnJump=1.0		--Number of degrees each movement makes. 1 = 1 degree every time; 0.5 = half a degree every time; ect.
TurnSpeed=0.0001	--Wait time between jumps
SpeedVariation=1		


Beam=script.Parent.Tilt.H1
CPan=0
CTilt=0

local Pan = Instance.new("Weld")
Pan.Part0 = script.Parent.Base
Pan.Part1 = script.Parent.Pan.Handle
Pan.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0,1,0)
Pan.Parent = script.Parent
local Tilt = Instance.new("Weld")
Tilt.Part0 = script.Parent.Pan.Center
Tilt.Part1 = script.Parent.Tilt.Handle
Tilt.C1 = CFrame.fromEulerAnglesXYZ(math.pi/-2, math.pi/2, 0) * CFrame.new(0,0,0)
Tilt.Parent = script.Parent

OneDegree=math.pi/180
function Degrees(Des)
	return(Des*OneDegree)
end

Colors={"Hot pink", "Really blue"}
function RandColor()
	return Colors[math.random(1, #Colors)]
end

function On(Color)
	Beam.BrickColor=BrickColor.new(Color)
	Beam.Transparency=0.3
end
function Off()
	Beam.Transparency=1
end

function Reach(PanDegree,TiltDegree,Speed)
	ReachedPan=false
	ReachedTilt=false
	Moving=true

	--Send out the directional degree spiders! They will go out and seek the shortest path around.
	Current=CPan
	Pos=0
	while Current~=PanDegree do
		Current=Current+TurnJump
		Pos=Pos+1
		if Current>359 then
			Current=Current-360
		end
	end
	Current=CPan
	Neg=0
	while Current~=PanDegree do
		Current=Current-TurnJump
		Neg=Neg+1
		if Current<0 then
			Current=Current+360
		end
	end
	Rand=math.random(1,2)	

	while ReachedPan==false or ReachedTilt==false and Moving==true do
		if CPan-0.5<PanDegree and CPan+0.5>PanDegree then
			ReachedPan=true
		end
		if CTilt-0.5<TiltDegree and CTilt+0.5>TiltDegree then
			ReachedTilt=true
		end
		if ReachedPan==false then
			PN=0					--] Deternine Direction of movement
			if Pos<Neg then			--]
				PN=1					--]
			elseif Neg<Pos then		--]
				PN=-1					--]
			elseif Neg==Pos then		--]
				if Rand==1 then			--]
					PN=-1					--]
				else						--]
					PN=1					--]
				end						--]
			end						--]

			CPan=CPan+TurnJump*PN
			if CPan>359 then
				CPan=CPan-360
			end
			if CPan<0 then
				CPan=360+CPan
			end	
			Pan.C1=Pan.C1*CFrame.fromEulerAnglesXYZ(0,Degrees(1)*PN*TurnJump,0)
		end
		if ReachedTilt==false then
			PN=0						--] Deternine Direction of movement
			if TiltDegree-CTilt<0 then		--]
				PN=-1						--]
			elseif TiltDegree-CTilt>=0 then	--]
				PN=1						--]
			end							--]
			CTilt=CTilt+PN*TurnJump
			Tilt.C1=Tilt.C1*CFrame.fromEulerAnglesXYZ(0,Degrees(1)*PN*TurnJump,0)
		end
		wait(Speed)
	end
end


function Move()
	Moving=false
	wait(script.Parent.Move.Value.Z*2)
	Reach(script.Parent.Move.Value.X,script.Parent.Move.Value.Y,script.Parent.Move.Value.Z)
end
script.Parent.Move.Changed:connect(Move)
while true do
	On(RandColor())
	Reach(math.random(0,159),math.random(-115,115),TurnSpeed+math.random(TurnSpeed*-SpeedVariation*1000000,TurnSpeed*SpeedVariation*1000000)/1000000)
end

