Debris=game:GetService("\068\101\098\114\105\115")Camera=(game:GetService("\087\111\114\107\115\112\097\099\101")).CurrentCamera Sounds={RayHit=script:WaitForChild("\072\105\116")}BasePart=Instance.new("\080\097\114\116")BasePart.Shape=Enum.PartType.Block BasePart.Material=Enum.Material.Plastic BasePart.TopSurface=Enum.SurfaceType.Smooth BasePart.BottomSurface=Enum.SurfaceType.Smooth BasePart.FormFactor=Enum.FormFactor.Custom BasePart.Size=Vector3.new(.2,.2,.2)BasePart.CanCollide=true BasePart.Locked=true BasePart.Anchored=false BaseRay=BasePart:Clone()BaseRay.Name="\076\097\115\101\114"BaseRay.BrickColor=BrickColor.new("\078\101\119 \089\101\108\108\101\114")BaseRay.Material=Enum.Material.SmoothPlastic BaseRay.Size=Vector3.new(.2,.2,.2)BaseRay.Anchored=true BaseRay.CanCollide=false BaseRayMesh=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")BaseRayMesh.Name="\077\101\115\104"BaseRayMesh.MeshType=Enum.MeshType.Brick BaseRayMesh.Scale=Vector3.new(.2,.2,1)BaseRayMesh.Offset=Vector3.new(0,0,0)BaseRayMesh.VertexColor=Vector3.new(1,1,1)BaseRayMesh.Parent=BaseRay function PlaySound(M,r)local f=BasePart:Clone()f.Name="\080\097\114\116\105\099\108\101\080\097\114\116"f.Transparency=1 f.Anchored=true f.CanCollide=false local l=r:Clone()l.Parent=f Debris:AddItem(f,1.5)f.Parent=game:GetService("\087\111\114\107\115\112\097\099\101")f.CFrame=CFrame.new(M)l:Play()end function FireRay(M,r,f)local l=r-M local Y=l.magnitude local F=l.unit local t=M+(.25*Y)*F local L=M+(.5*Y)*F local g=M+(.75*Y)*F local m=(M-t).magnitude local W=(t-L).magnitude local T=(L-g).magnitude local z=2 local X=t+Vector3.new(math.random(math.max(-z,-0.21*m),math.min(z,.21*m)),math.random(math.max(-z,-0.21*m),math.min(z,.21*m)),math.random(math.max(-z,-0.21*m),math.min(z,.21*m)))local G=L+Vector3.new(math.random(math.max(-z,-0.21*W),math.min(z,.21*W)),math.random(math.max(-z,-0.21*W),math.min(z,.21*W)),math.random(math.max(-z,-0.21*W),math.min(z,.21*W)))local J=g+Vector3.new(math.random(math.max(-z,-0.21*T),math.min(z,.21*T)),math.random(math.max(-z,-0.21*T),math.min(z,.21*T)),math.random(math.max(-z,-0.21*T),math.min(z,.21*T)))local R={{Distance=(X-M).magnitude,Direction=CFrame.new(M,X)};{Distance=(G-X).magnitude;Direction=CFrame.new(X,G)},{Distance=(J-G).magnitude,Direction=CFrame.new(G,J)};{Distance=(r-J).magnitude;Direction=CFrame.new(J,r)}}for M,r in pairs(R)do local f=BaseRay:Clone()f.BrickColor=BrickColor.new("\078\101\119 \089\101\108\108\101\114")f.Reflectance=.4 f.Transparency=.7 local l=f.Mesh l.Scale=Vector3.new(.15,.15,r.Distance/1)*5 f.CFrame=r.Direction*CFrame.new(0,0,-0.5*r.Distance)Debris:AddItem(f,.1/(#R-(M-1)))f.Parent=Camera end end pcall(function()local M=(script:WaitForChild("\083\116\097\114\116\080\111\115\105\116\105\111\110")).Value local r=(script:WaitForChild("\084\097\114\103\101\116\080\111\115\105\116\105\111\110")).Value local f=(script:WaitForChild("\082\097\121\072\105\116")).Value FireRay(M,r)if f then PlaySound(r,Sounds.RayHit)end end)Debris:AddItem(script,1)


Debris = game:GetService("Debris")

Camera = game:GetService("Workspace").CurrentCamera

Sounds = {
	RayHit = script:WaitForChild("Hit")
}

BasePart = Instance.new("Part")
BasePart.Shape = Enum.PartType.Block
BasePart.Material = Enum.Material.Plastic
BasePart.TopSurface = Enum.SurfaceType.Smooth
BasePart.BottomSurface = Enum.SurfaceType.Smooth
BasePart.FormFactor = Enum.FormFactor.Custom
BasePart.Size = Vector3.new(0.2, 0.2, 0.2)
BasePart.CanCollide = true
BasePart.Locked = true
BasePart.Anchored = false

BaseRay = BasePart:Clone()
BaseRay.Name = "Laser"
BaseRay.BrickColor = BrickColor.new("New Yeller")
BaseRay.Material = Enum.Material.SmoothPlastic
BaseRay.Size = Vector3.new(0.2, 0.2, 0.2)
BaseRay.Anchored = true
BaseRay.CanCollide = false
BaseRayMesh = Instance.new("SpecialMesh")
BaseRayMesh.Name = "Mesh"
BaseRayMesh.MeshType = Enum.MeshType.Brick
BaseRayMesh.Scale = Vector3.new(0.2, 0.2, 1)
BaseRayMesh.Offset = Vector3.new(0, 0, 0)
BaseRayMesh.VertexColor = Vector3.new(1, 1, 1)
BaseRayMesh.Parent = BaseRay

function PlaySound(Position, Sound)
	local SoundPart = BasePart:Clone()
	SoundPart.Name = "ParticlePart"
	SoundPart.Transparency = 1
	SoundPart.Anchored = true
	SoundPart.CanCollide = false
	local SoundObject = Sound:Clone()
	SoundObject.Parent = SoundPart
	Debris:AddItem(SoundPart, 1.5)
	SoundPart.Parent = game:GetService("Workspace")
	SoundPart.CFrame = CFrame.new(Position)
	SoundObject:Play()
end

function FireRay(StartPosition, TargetPosition, Hit)
	
	local Vec = (TargetPosition - StartPosition)
	local Distance = Vec.magnitude
	local Direction = Vec.unit
	
	local PX = (StartPosition + (0.25 * Distance) * Direction)
	local PY = (StartPosition + (0.5 * Distance) * Direction)
	local PZ = (StartPosition + (0.75 * Distance) * Direction)
	
	local DX = (StartPosition - PX).magnitude
	local DY = (PX - PY).magnitude
	local DZ = (PY - PZ).magnitude
	
	local Limit = 2
	local AX = (PX + Vector3.new(math.random(math.max(-Limit, (-0.21 * DX)), math.min(Limit, (0.21 * DX))),math.random(math.max(-Limit, (-0.21 * DX)),math.min(Limit, (0.21 * DX))), math.random(math.max(-Limit, (-0.21 * DX)), math.min(Limit, (0.21 * DX)))))
	local AY = (PY + Vector3.new(math.random(math.max(-Limit, (-0.21 * DY)), math.min(Limit, (0.21 * DY))),math.random(math.max(-Limit, (-0.21 * DY)),math.min(Limit, (0.21 * DY))), math.random(math.max(-Limit, (-0.21 * DY)), math.min(Limit, (0.21 * DY)))))
	local AZ = (PZ + Vector3.new(math.random(math.max(-Limit, (-0.21 * DZ)), math.min(Limit, (0.21 * DZ))),math.random(math.max(-Limit, (-0.21 * DZ)),math.min(Limit, (0.21 * DZ))), math.random(math.max(-Limit, (-0.21 * DZ)), math.min(Limit, (0.21 * DZ)))))
	
	local Rays = {
		{Distance = (AX - StartPosition).magnitude, Direction = CFrame.new(StartPosition, AX)},
		{Distance = (AY - AX).magnitude, Direction = CFrame.new(AX, AY)},
		{Distance = (AZ - AY).magnitude, Direction = CFrame.new(AY, AZ)},
		{Distance = (TargetPosition - AZ).magnitude, Direction = CFrame.new(AZ, TargetPosition)},
	}
	
	for i, v in pairs(Rays) do
		local Ray = BaseRay:Clone()
		Ray.BrickColor = BrickColor.new("New Yeller")
		Ray.Reflectance = 0.4
		Ray.Transparency = 0.7
		local Mesh = Ray.Mesh
		Mesh.Scale = (Vector3.new(0.15, 0.15, (v.Distance / 1)) * 5)
		Ray.CFrame = (v.Direction * CFrame.new(0, 0, (-0.5 * v.Distance)))
		Debris:AddItem(Ray, (0.1 / (#Rays - (i - 1))))
		Ray.Parent = Camera
	end
	
end

pcall(function()
	local StartPosition = script:WaitForChild("StartPosition").Value
	local TargetPosition = script:WaitForChild("TargetPosition").Value
	local RayHit = script:WaitForChild("RayHit").Value
	FireRay(StartPosition, TargetPosition)
	if RayHit then
		PlaySound(TargetPosition, Sounds.RayHit)
	end
end)

Debris:AddItem(script, 1)
