function core.findAngle(C,c,r)local O=r.Orientation.Y local p=math.atan2(c.Z-C.Z,c.X-C.X)local b=(math.deg(p)+O)+90 if b>180 then b=-(360-b)elseif b<-180 then b=360+b end return b end function core.findPitch(C,c,r)local O=r.Orientation.X local p=math.atan2(c.Y-C.Y,math.abs(c.Z-C.Z))local b=math.deg(p)+O if b>180 then b=-(360-b)elseif b<-180 then b=360+b end return b end function core.tempAttach(C,c)local r=Instance.new("\065\116\116\097\099\104\109\101\110\116")r.WorldPosition=C r.Parent=workspace.Terrain debrisService:AddItem(r,c)return r end function core.playSound(C,c)local r=core.tempAttach(c,C.TimeLength)local O=C:Clone()O.Parent=r O:Play()end return core

function core.findAngle(pos1,pos2,part)
	local yOrientation = part.Orientation.Y
	local rot = math.atan2(pos2.Z-pos1.Z, pos2.X-pos1.X)


	local desiredAngle = math.deg(rot)+yOrientation+90
	if desiredAngle > 180 then
		desiredAngle = -(360-desiredAngle)
	elseif desiredAngle <-180 then
		desiredAngle = 360+desiredAngle
	end	

	return desiredAngle
end

function core.findPitch(pos1,pos2,part)
	local xOrientation = part.Orientation.X
	local rot = math.atan2(pos2.Y-pos1.Y, math.abs(pos2.Z-pos1.Z))
	
	local desiredAngle = math.deg(rot)+xOrientation
	if desiredAngle > 180 then
		desiredAngle = -(360-desiredAngle)
	elseif desiredAngle <-180 then
		desiredAngle = 360+desiredAngle
	end	

	return desiredAngle
end

function core.tempAttach(pos,life)
	local attach = Instance.new("Attachment")
	attach.WorldPosition = pos
	attach.Parent = workspace.Terrain
	
	debrisService:AddItem(attach,life)
	
	return attach
end

function core.playSound(sound,pos)
	local attach = core.tempAttach(pos,sound.TimeLength)
	local soundClone = sound:Clone()
	soundClone.Parent = attach
	soundClone:Play()
end




return core
