--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 * .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(.1, .1, dis + .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
