local d={shock=1;bolt=1,bullet=1,plasma=1,effect=1;laser=1,handle=1;effects=1;flash=1}function CheckIntangible(y)print(y.Name)return d[string.lower(y.Name)]or y.Transparency==1 end function CastRay(d,y,I,t,Z)if I>999 then I=999 end hit,endpos2=game.Workspace:FindPartOnRay(Ray.new(d,y*I),t)if hit~=nil then if CheckIntangible(hit)then if Z then wait()end hit,endpos2=CastRay(endpos2+y*.01,y,I-(d-endpos2).magnitude,t,Z)end end return hit,endpos2 end function DrawBeam(d,y,I,t,Z)local a=2 local X=Z:Clone()X.BrickColor=I X.Size=Vector3.new(.1,.1,a+.2)X.CFrame=CFrame.new((y+d)/2,d)*CFrame.new(0,0,-a/2)X.Parent=game.Workspace game.Debris:AddItem(X,t)end
--this is a little bad, but shouldn't really be part of the 'class' of the gun
local Intangibles =
	{ shock = 1, bolt = 1, bullet = 1, plasma = 1, effect = 1, laser = 1, handle = 1, effects = 1, flash = 1 }
function CheckIntangible(hitObj)
	print(hitObj.Name)
	return Intangibles[(string.lower(hitObj.Name))] or hitObj.Transparency == 1
end

function CastRay(startpos, vec, length, ignore, delayifhit)
	if length > 999 then
		length = 999
	end
	hit, endpos2 = game.Workspace:FindPartOnRay(Ray.new(startpos, vec * length), ignore)
	if hit ~= nil then
		if CheckIntangible(hit) then
			if delayifhit then
				wait()
			end
			hit, endpos2 =
				CastRay(endpos2 + (vec * 0.01), vec, length - (startpos - endpos2).magnitude, ignore, delayifhit)
		end
	end
	return hit, endpos2
end

function DrawBeam(beamstart, beamend, clr, fadedelay, templatePart)
	local dis = 2 --(beamstart - beamend).magnitude
	local tlaser = templatePart:Clone()
	tlaser.BrickColor = clr
	tlaser.Size = Vector3.new(0.1, 0.1, dis + 0.2)
	tlaser.CFrame = CFrame.new((beamend + beamstart) / 2, beamstart) * CFrame.new(0, 0, -dis / 2)
	tlaser.Parent = game.Workspace
	game.Debris:AddItem(tlaser, fadedelay)
end
