function CastLightRay(V,q,d,g,P,M,b)local l,t=game.Workspace:FindPartOnRay(Ray.new(V,(q-V).unit*999.999),Tool.Parent)if t then q=t end if l and l.Parent then if l.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")and l.Parent~=Tool.Parent then b(l.Parent.Humanoid,(q-V).unit)elseif l.Parent.Parent and(l.Parent.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")and l.Parent.Parent~=Tool.Parent)then b(l.Parent.Parent.Humanoid,(q-V).unit)end end local N=math.floor(math.min((V-q).magnitude/g,50))local k=#M for V=N,k,1 do if M[V]then M[V]:Destroy()M[V]=nil end end for P=1,N,1 do if not M[P]then M[P]=Instance.new("\080\097\114\116")M[P].Parent=Tool M[P].Anchored=true M[P].FormFactor="\067\117\115\116\111\109"M[P].Size=Vector3.new(0,0,g)M[P].CanCollide=false local V=Instance.new("\080\111\105\110\116\076\105\103\104\116")V.Name="\076\105\103\104\116"V.Parent=M[P]end M[P].BrickColor=d;(M[P]:WaitForChild("\076\105\103\104\116")).Color=d.Color M[P].Light.Range=(math.sin(tick()*3)+1)*1+5 M[P].Light.Brightness=(math.sin(tick()*3)+1)*1+1 M[P].CFrame=CFrame.new(((P-.4)*(q-V).unit)*g+V,q)end return M end
--

function CastLightRay(startPos,endPos,color,segLength,segSpeed,parts,effectfunc)
	local part, nend = game.Workspace:FindPartOnRay( Ray.new(startPos,(endPos-startPos).unit*999.999),Tool.Parent)
	if nend then endPos = nend end
	
	if part and part.Parent then
		if part.Parent:FindFirstChild('Humanoid') and part.Parent ~=Tool.Parent then
			effectfunc(part.Parent.Humanoid,(endPos-startPos).unit)
		elseif part.Parent.Parent and part.Parent.Parent:FindFirstChild('Humanoid')  and part.Parent.Parent~=Tool.Parent then
			effectfunc(part.Parent.Parent.Humanoid,(endPos-startPos).unit)
		end
	end	
	
	
	local numSegments = math.floor(math.min((startPos-endPos).magnitude/segLength,50))
	local initNumParts = #parts
	for i=numSegments,initNumParts,1 do
		if parts[i] then
			parts[i]:Destroy()
			parts[i]=nil
		end
	end
	for i=1,numSegments,1 do
		if not parts[i] then
			parts[i] = Instance.new('Part')
			parts[i].Parent = Tool
			parts[i].Anchored = true
			parts[i].FormFactor = 'Custom'
			parts[i].Size = Vector3.new(0,0,segLength)
			parts[i].CanCollide = false
			local tlight = Instance.new('PointLight')
			tlight.Name = 'Light'
			tlight.Parent = parts[i]
			
		end
		parts[i].BrickColor = color
		parts[i]:WaitForChild('Light').Color = color.Color
		parts[i].Light.Range =((math.sin(tick()*3)+1)*1)+5
		parts[i].Light.Brightness =((math.sin(tick()*3)+1)*1)+1

		parts[i].CFrame = CFrame.new(((i-.4)*(endPos-startPos).unit*segLength)+startPos,endPos)

	end
	
	return parts
end
